Photocatalysts are crucial to diverse applications, but a challenge is the simultaneous and efficient delivery of photogenerated charges and mass to the catalytic sites. Now, through the systematic design of the skeleton and pores, a covalent organic framework is developed for the efficient photosynthesis of hydrogen peroxide using only water, air and light.