The rechargeable lithium/sodium-iodine battery (Li/Na-I 2 ) is a promising candidate for meeting the growing energy demand. Herein, a flexible hydrogenbonded organic framework (HOF) linked to the Ti 3 C 2 T x MXene complex (HOF@Ti 3 C 2 T x ) has been presented for iodine loading. HOF is self-assembled by organic monomers through hydrogen bonding interactions between each monomer. It leads to numerous cavities in HOF structure, which can encapsulate iodine through various adsorptive sites and intermolecular interactions. The unique structure of complex can accelerate the nucleation of iodine, achieve fast reaction kinetics, stabilize iodide and retard the shuttle effect, thus improving the cycling stability of I 2 -based batteries. The I 2 /HOF@Ti 3 C 2 T x exhibits large reversible capacities of 260.2 and 207.6 mAh g À 1 at 0.2 C after repeated cycling for Li-I 2 and Na-I 2 batteries, respectively. This work can gain insights into the HOF-related energy storage application with reversible iodine encapsulation and its related redox reaction mechanisms with Li and Na metal ions.