In-situ ligand bonding management of CsPbI3 perovskite quantum dots enables high-performance photovoltaics and red light-emitting diodes.