Microenvironments in heterogeneous catalysis have been recognized as equally important as the types and amounts of active sites for regulating catalytic activity. Two-dimensional (2D) nanospaces between van der Waals (vdW) gaps of layered materials provide an ideal microenvironment to create novel functionalities. Here, we explore a facile method for fabricating g-C3N4/2H-MoS2 superlattice-like heterostructures based on thermochemical intercalation and polymerization reactions of formamide within enlarged vdW gaps of 2H-MoS2 nanosheets without any transfer process. DFT calculations demonstrate that the interlayer electron-electron correlations due to the intercalation effect of g-C3N4, rather than high-κ dielectric environments, lead to the improvement of intrinsic conductivity of 2H-MoS2 nanosheets. As the proof of concept in applications for the electrocatalysis field, the heterostructure for hydrogen electrochemical reaction (HER) exhibits high stability and catalytic activity in both acid and alkaline media, such as a quite low onset overpotential of 98 mV, a high exchange current density of 77.6 μA cm-2, and a small Tafel slope (52.9 mV dec-1) in an acid medium. The enhanced HER activity is attributed to the improved conductivity and nanoconfinement effect of 2D nanospaces that decrease the reaction activation energy and activate the inert basal planes.