In our work, a flurry of original porphyrin-based polymers covalently functionalized g-C3N4 nanohybrids were constructed and nominated as PPorx-g-C3N4 (x = 1, 2 and 3) through click chemistry between porphyrin-based polymers with alkyne end-groups [(PPorx-C≡CH (x = 1, 2 and 3)] and azide-functionalized graphitic carbon nitride (g-C3N4-N3). Due to the photoinduced electron transfer (PET) between porphyrin-based polymers [PPorx (x = 1, 2 and 3)] group and graphite phase carbon nitride (g-C3N4) group in PPorx-g-C3N4 nanohybrids, the PPorx-g-C3N4 nanohybrids exhibited better non-linear optical (NLO) performance than the corresponding PPorx-C≡CH and g-C3N4-N3. It found that the imaginary third-order susceptibility (Im [χ(3)]) value of the nanohybrids with different molecular weight (MW) of the pPorx group in the nanohybrids ranged from 2.5×103 to 7.0 × 103gmol-1 was disparate. Quite interestingly, the Im [χ(3)] value of the nanohybrid with a pPorx group'sMW of 4.2 × 103gmol-1 (PPor2-g-C3N4) was 1.47 × 10-10 esu, which exhibited the best NLO performance in methyl methacrylate (MMA) of all nanohybrids. The PPorx-g-C3N4 was dispersed in polymethyl methacrylate (PMMA) to prepare the composites PPorx-g-C3N4/PMMA since PMMA was widely used as an alternative to glass. PPor2-g-C3N4/PMMA showed the excellent NLO performance of all nanohybrids with the Im [χ(3)] value of 2.36 × 10-10 esu, limiting threshold of 1.71J/cm2, minimum transmittance of 8% and dynamic range of 1.09 in PMMA, respectively. It suggested that PPorx-g-C3N4 nanohybrids were potential outstanding NLO materials.