A facile two-step route is used to synthesize core–shell structured NaYF4: Yb, Er/g-C3N4 nanocomposites (NaYF4/CN). A hot cyanuric acid solution and a melamine solution are put into a NaYF4: Yb, Er colloid to form ternary NaYF4: Yb, Er-cyanuric acid-melamine (NaYF4/CM) adducts. And then, the prismatic NaYF4/CM composites are annealed at 550°C, which results in a structure change from NaYF4/CM to NaYF4/CN. The g-C3N4 shell of NaYF4/CN weakens the surface luminescence quenching of the NaYF4: Yb, Er core. So the NaYF4/CN shows stronger upconversion (UC) luminescence than pure cubic NaYF4: Yb, Er nanoparticles. Besides, under excitation of 335nm, NaYF4/CN shows weaker downshifting luminescence than bulk g-C3N4.