WS2 nanoflakes have great potential as electrode materials of lithium-ion batteries (LIBs) and sodium-ion batteries (SIBs) because of their unique 2D structure, which facilitates the reversible intercalation and extraction of alkali metal ions. However, a fundamental understanding of the electrochemical lithiation/sodiation dynamics of WS2 nanoflakes especially at the nanoscale level, remains elusive. Here, by combining battery electrochemical measurements, density functional theory calculations, and in situ transmission electron microscopy, the electrochemical-reaction kinetics and mechanism for both lithiation and sodiation of WS2 nanoflakes are investigated at the atomic scale. It is found that compared to LIBs, SIBs exhibit a higher reversible sodium (Na) storage capacity and superior cyclability. For sodiation, the volume change due to ion intercalation is smaller than that in lithiation. Also, sodiated WS2 maintains its layered structure after the intercalation process, and the reduced metal nanoparticles after conversion in sodiation are well-dispersed and aligned forming a pattern similar to the layered structure. Overall, this work shows a direct interconnection between the reaction dynamics of lithiated/sodiated WS2 nanoflakes and their electrochemical performance, which sheds light on the rational optimization and development of advanced WS2 -based electrodes.