Two dimensional materials have promising benefits in photoelectronic devices, including facilitating charge transport and reducing defects in perovskite solar cells (PSCs) and photodetectors (PDs) through interface engineering. Herein, a two dimension polymeric material of graphitic carbon nitride quantum dots (g-CNQDs) interlayer is used to modify the SnO2/perovskite interface in both ambient PSCs and PDs to improve the overall performance. The introduction of g-CNQD layer improves the crystalline quality of sequential perovskite absorber with high phase purity, less grain boundaries, low trap states and suppressed carrier recombination due to the intrinsic cross-linkable feature and relatively smooth surface of g-CNQD. As a result, with optimal modification, fully air-processed PSC reached a champion power conversion efficiency of 21.23% with negligible hysteresis, and the PDs had remarkable performance enhancement. Moreover, our PSCs have good stability in ambient air, keeping over 90% of the initial efficiency after 30 days’ exposure.