The stability, electronic structures, work function, and optical properties of single-layer g-C3N4 and X/ g-C3N4 (X = g-C3 N4 , AlN and GaN) heterostructures were investigated using plane-wave density functional theory with ultra-soft pseudopotentials. The results show that the lattice mismatch ratio and lattice mismatch energy of X/ g-C3N4 heterojunction are very low, indicating that X/ g-C3N4 heterojunction has excellent stability. Compared with the single-layer g-C3N4, the bandgap of the X/ g-C3N4 all reduces, and the peaks and troughs of the density of states greatly improves. At the same time, X/ g-C3N4 has a redshift, which leds to an increase in the number of electrons in the excited state, making electronic transitions easier. It shows that the heterojunction is beneficial to improves the response-ability of the system to visible light, and effectively improves the photocatalytic activity of the system. Further calculations show that the work function of X/ g-C3N4 reduces and a built-in electric field is formed at the interface, which inhibits the recombination of photo-generated electron-hole pairs. This is of great benefit to the migration of carriers and the improvement of photocatalytic ability. Among them, the GaN/ g-C3 N4 heterojunction has the smallest work function, the potential difference at the interface formed a built-in electric field and the redshift is the most obvious. It can be inferred that the GaN/ g-C3 N4 heterojunction has the best photocatalytic activity. Therefore, the heterojunction proposed in this paper is an effective means to improve the photocatalytic activity of the system. [ABSTRACT FROM AUTHOR]