Energy storage materials have advanced renewable energy technologies. Herein, we described the one-pot synthesis of covalent organic frameworks (COFs)/graphitic carbon nitride (g-C 3 N 4 ) nanocomposite. The condensation of melamine and benzene-1,3,5-tricarboxyaldehyde with and without g-C 3 N 4 offered the synthesis of COF and COF/g-C 3 N 4 . Furthermore, N-doped carbon and N-doped carbon/g-C 3 N 4 were synthesized via the carbonization of COF and COF/g-C 3 N 4 , respectively. The materials i.e., before and after carbonization were used as electrode materials for supercapacitors and lithium-ion batteries (LIBs). They showed specific capacitance of 211, 257.5, 450, and 835.2 F•g −1 for COF, COF/g-C 3 N 4 , N-doped carbon, and N-doped carbon/ g-C 3 N 4 , respectively. Asymmetric supercapacitor device using N-doped carbon/g-C 3 N 4 exhibited good energy (45.97 Wh•kg −1 ) with high power (659.3 W•kg −1 ). The N-doped C/g-C 3 N 4 electrode was also applied for LIBs, offering a discharge capacity of 390 mAh•g −1 (at 50 mA•g −1 ).