The compilation of the Qur'an into a single book took place during the time of Caliph Abu Bakr, following the death of Prophet Muhammad (peace be upon him). This effort was initiated **on the advice of Umar ibn Khattab**. After the Battle of Yamama, where many companions who had memorized the Qur'an were killed, Umar approached Abu Bakr, expressing his concern that the Qur'an might be lost. He suggested that it should be compiled into a single written volume to ensure its preservation.
Initially, Abu Bakr was hesitant, as the Prophet had not undertaken such a task during his lifetime. However, after careful consideration and persuasion by Umar, he agreed to the proposal for the safety and preservation of the Qur'an. Abu Bakr then appointed Zayd ibn Thabit, a trusted scribe of the Prophet, to undertake the task of gathering and compiling the Qur'an from various written fragments and the memories of those who had memorized it.
This initial compilation was kept with Abu Bakr, and later with his successor, Caliph Umar, and was eventually entrusted to Hafsa, the daughter of Umar. This effort laid the foundation for the preservation of the Qur'an as we know it today.