Photocatalytic CO2 conversion promises an ideal route to store solar energy into chemical bonds. However, sluggish electron kinetics and unfavorable product selectivity remain unresolved challenges. Here, an ionic liquid, 1-ethyl-3-methylimidazolium tetrafluoroborate, and borate-anchored Co single atoms were separately loaded on ultrathin g-C3N4 nanosheets. The optimized nanocomposite photocatalyst produces CO and CH4 from CO2 and water under UV–vis light irradiation, exhibiting a 42-fold photoactivity enhancement compared with g-C3N4 and nearly 100% selectivity towards CO2 reduction. Experimental and theoretical results reveal that the ionic liquid extracts electrons and facilitates CO2 reduction, whereas Co single atoms trap holes and catalyze water oxidation. More importantly, the maximum electron transfer efficiency for CO2 photoreduction, as measured with in-situ μs-transient absorption spectroscopy, is found to be 35.3%, owing to the combined effect of the ionic liquid and Co single atoms. This work offers a feasible strategy for efficiently converting CO2 to valuable chemicals.