Perovskite solar cells are affordable and work well but don’t last. A method fixes this problem without common trade-offs.