Correction to: Nature https://doi.org/10.1038/s41586-024-08080-x Published online 23 October 2024

In the version of the article initially published, in the Supplementary information, the SEM image of COF-999-NH2 in Supplementary Fig. 1 was incorrect and has now been amended. Additionally, the x-axis units of the middle graphs in Supplementary Figs. 2–4 have been updated from “(cm3 g–1, STP)” to “(g cm–3, STP)”. The updated Supplementary information can be found online.