A novel and simple in situ synthetic strategy was used to fabricate CdS/g-C 3 N 4 hybrid nanocomposite catalysts with visible-light-driven photocatalytic activity from cadmium-containing carbon nitride compounds. X-ray diffraction measurements, high-resolution transmission electron microscopy images, and Fourier transform infrared spectra showed heterojunctions with a close interface between the g-C 3 N 4 and the CdS nanoparticles and nanorods in the composite. Ultraviolet visible diffuse reflectance spectra exhibited a red shift that further presented the CdS in the polymer g-C 3 N 4 skeleton, which allowed the efficient utilization of the solar spectrum for creating photogenerated electrons and holes. The photoluminescence spectra of the nanocomposites suggested charge transfer from g-C 3 N 4 to CdS. The photocurrent intensity of hybrid nanocomposites was 2.3 times than that of pure g-C 3 N 4 sample, and photocatalytic activity for the photodegradation of methyl orange was 2.5 times, and hydrogen evolution reaction was 2.8 times. Enhanced photocatalytic activity and photocurrent for the CdS/g-C 3 N 4 hybrid nanocomposites were achieved.