Two experiments from the Fermilab, E989 and CDF II, have reported two anomalies for muon anomalous magnetic moment ($g-2$) and $W$-boson mass that may indicate the new physics at the low energy scale. Here we examine the possibility of a common origin of these two anomalies in the Next-to-Minimal Supersymmetric Standard Model. Considering various experimental and astrophysical constraints such as the Higgs mass, collider data, B-physics, dark matter relic density and direct detection experiments, we find that a neutralino in the mass range of $\sim 150-290$ GeV is a viable solution. Moreover, the favored parameter region can be effectively probed by the ongoing direct detection experiments like LZ, PandaX-4T and XENON-nT. The velocity avera...