AbstractThe necessity for the development and enhancement of teacher commitment to satisfying students' learning needs in response to the COVID crisis is increasingly highlighted. It is not known, however, how to increase commitment in schoolteachers to boost online teaching in light of the fact that they, too, are struggling to cope with the rapid, unexpected change. A total of 601 teachers from primary and secondary schools across China participated in this study, with an average teaching experience of 15.9 years. Structural equation modelling was used to verify the significance of contextual, cognitive, affective and behavioural factors in boosting teachers' commitment to online teaching. The findings demonstrated that teacher agency played a complete mediating role in the predicting power of other factors to teacher commitment. Therefore, it was recommended that attention be paid to the practice and opportunities for teacher agentic actions, which necessitates real encounters with online teaching, allowing teachers to act meaningfully and initiate a new set of teaching strategies. Practitioner notesWhat is already known about this topic The large‐scale transition to emergency online teaching serves as the catalyst for creating a blended or hybrid model of education provision in the long term. How hard teachers work to perform at their best and overcome obstacles to support students' learning needs in new environment relies on the intensity of teacher commitment to change. Online and blended learning requires teachers to not only be prepared for a diverse learning environment but also to build and rebuild their own identity as future teachers. What this paper adds This study adds to our knowledge of how traditional F2F classroom teachers reinvented their roles and responsibilities in response to the pandemic‐driven challenges based on real‐world experiences. As a result of the COVID‐19 lockdown school closures, schoolteachers' commitment to enhancing online teaching efforts has increased. The study highlights the complete mediating role of teacher agency in the predicting power of cognitive and affective factors to teacher commitment. Implications for practice and/or policy To learn more about how to be a good online teacher, future teachers need greater deliberate effort in diverse online teaching activities. Future teachers should be equipped with not only new technological and remote instructional strategies and skills, but also with confidence in, value for, and actual experiences with online teaching in a technology‐rich environment. For teachers to obtain hands‐on experience in integrating technology with distance teaching pedagogy at a time of rapid change, schools should have some days online and offer blended learning opportunities wherever possible.