In this work, the hydrogen storage properties of a g-C3N4 monolayer decorated with both Mg and Li were thoroughly investigated by performing density functional theory (DFT) calculations. Along these lines, the projected densities of states (PDOS) and the Bader Charge analysis showed that both Mg and Li atoms can transfer their electronic charges to the g-C3N4 monolayer. Interestingly, the latter is transformed from a semiconductor material to a metallic conductor configuration, while a local electric field is formed around it. On top of that, the formed local electric field polarized hydrogen molecules and as a result, led to an enhanced hydrogen adsorption ability. Mg atoms have more outmost electrons, and more charges can be transferred to the monolayer, which leads to the creation of a stronger local electric field to adsorb an elevated number of hydrogen molecules than Li atoms. On the other hand, Li atoms are lighter, more active and easier to lose outmost electrons than Mg atoms. By considering these advantages, a g-C3N4 monolayer decorated with one unit of both Mg and Li was investigated, which has the ability to adsorb 10 hydrogen molecules, leading thus to a high hydrogen storage capacity of 10.01 wt %. Our work paves the way for the development of novel material configurations for improved hydrogen storage applications.