Amorphous metal oxides are useful in optical, electronic and electrochemical devices. The bonding arrangement within these glasses largely determines their properties, yet it remains a challenge to manipulate their structures in a controlled manner. Recently, we developed synthetic protocols for incorporating nanocrystals that are covalently bonded into amorphous materials. This ‘nanocrystal-in-glass’ approach not only combines two functional components in one material, but also the covalent link enables us to manipulate the glass structure to change its properties. Here we illustrate the power of this approach by introducing tin-doped indium oxide nanocrystals into niobium oxide glass (NbOx), and realize a new amorphous structure as a consequence of linking it to the nanocrystals. The resulting material demonstrates a previously unrealized optical switching behaviour that will enable the dynamic control of solar radiation transmittance through windows. These transparent films can block near-infrared and visible light selectively and independently by varying the applied electrochemical voltage over a range of 2.5 volts. We also show that the reconstructed NbOx glass has superior properties—its optical contrast is enhanced fivefold and it has excellent electrochemical stability, with 96 per cent of charge capacity retained after 2,000 cycles.