Developing low-cost and stable materials for converting solar energy into electricity is vital in meeting the world's energy demand. Metal-organic frameworks (MOFs) have gained attention for solar cells due to their natural porous architectures and tunable chemical structures. This review commences with an exploration of the synthetic methods of MOFs. Moreover, we discuss the various roles of MOFs, including photoanodes and counter electrodes in dye-sensitized solar cells and interfacial layers and charge carriers in perovskite solar cells. Ultimately, burdensome tasks and possible directions for advancing MOFs-based nanomaterials are provided for solar cells.