M dwarfs are the most numerous stars in the solar vicinity. They constitute privileged targets in the search for planetary systems in the habitable zone and their characterization. Several instruments were designed specifically to study M dwarfs, such as SPIRou, a high resolution spectro-polarimeter covering a large near-infrared range from 1 to 2.5 $\mu m$. Deriving the fundamental parameters of these stars is essential to the characterization of the companions, but remains a challenging task. In this talk, we discuss a method relying on the comparison to synthetic spectra to derive the effective temperature ($T_{\rm eff}$), the surface gravity ($\log{g}$) and metallicity ([M/H]) of M dwarfs from SPIRou observations. We demonstrate our abi...