Decoupling solar energy conversion and storage in a single material offers a great advantage for off-grid applications. Herein, we disclose a two-dimensional naphthalenediimide (NDI)-based covalent organic framework (COF) exhibiting remarkable solar battery performance when used as a photoanode. Light-induced radicals are stabilized within the framework for several hours, offering on-demand charge extraction for electrical energy production. Our study reveals mechanistic insights into the long-term charge stabilization using optical spectroscopy and (photo)electrochemical measurements, in conjunction with density functional theory (DFT) simulations. Among several solvents, water provides the best dielectric screening and energetically favorable proton exchange to stabilize photoinduced radicals for more than 48 h without the need for additional metal cations. This study provides fundamental insights into the optoionic charge storage mechanism in NDI-COF, while introducing a highly tunable, nanoporous material platform that surpasses related materials, such as carbon nitrides, metal-organic frameworks (MOFs), or metal oxides, in terms of charge storage capacity. This study opens new perspectives for the design of optoionic charge-storing materials and the direct storage of solar energy to overcome the intermittency of solar irradiation.