Sensitive and selective optoelectronic detection of NO2with g-C3N4(CN) is critical, but it remains challenging to achieve ultralow concentration (ppb-level) detection. Herein, Ni metal–organic frameworks/CN nanosheet heterojunctions were successfully fabricated by the electrostatic induced assembly strategy and then treated by a post-alkali etching process for creating coordinatively unsaturated Ni(II) sites. The optimized heterojunction exhibits a record detection limitation of 1 ppb for NO2, well below that observed on pristine CN, and an outstanding selectivity over other gases, along with long-time stability (120 days) at room temperature. The resulting superior detection performance benefits from the enhanced charge transfer and separation of the closely contacted heterojunction interface and the favorable adsorption of NO2by unsaturated Ni(II) as selective adsorption sites mainly by means of the time-resolved photoluminescence spectra and in situX-ray photoelectron spectra. Moreover, the in situFourier transform infrared spectra and temperature-programmed desorption disclose that the promotion adsorption of NO2depends on the strengthened interaction between NO2and Ni(II) node sites at the aid of OH groups from unsaturated coordination. This work offers a versatile solution to develop promising CN-based optoelectronic sensors at room temperature.