Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
ibnmajah:751Isḥāq b. Manṣūr > ʿAbdullāh b. Numayr > ʿUbaydullāh b. ʿUmar > Nāfiʿ > Ibn ʿUmar

"We used to sleep in the mosque at the time of the Messenger of Allah."  

ابن ماجة:٧٥١حَدَّثَنَا إِسْحَاقُ بْنُ مَنْصُورٍ حَدَّثَنَا عَبْدُ اللَّهِ بْنُ نُمَيْرٍ أَنْبَأَنَا عُبَيْدُ اللَّهِ بْنُ عُمَرَ عَنْ نَافِعٍ عَنِ ابْنِ عُمَرَ قَالَ

كُنَّا نَنَامُ فِي الْمَسْجِدِ عَلَى عَهْدِ رَسُولِ اللَّهِ ﷺ  


See similar narrations below:

Collected by Tirmidhī
tirmidhi:321Maḥmūd b. Ghaylān > ʿAbd al-Razzāq > Maʿmar > al-Zuhrī > Sālim > Ibn ʿUmar

"We would sleep in the Masjid during the time of Messenger of Allah and we were young men."  

الترمذي:٣٢١حَدَّثَنَا مَحْمُودُ بْنُ غَيْلاَنَ حَدَّثَنَا عَبْدُ الرَّزَّاقِ أَخْبَرَنَا مَعْمَرٌ عَنِ الزُّهْرِيِّ عَنْ سَالِمٍ عَنِ ابْنِ عُمَرَ قَالَ

كُنَّا نَنَامُ عَلَى عَهْدِ رَسُولِ اللَّهِ ﷺ فِي الْمَسْجِدِ وَنَحْنُ شَبَابٌ  

قَالَ أَبُو عِيسَى حَدِيثُ ابْنِ عُمَرَ حَدِيثٌ حَسَنٌ صَحِيحٌ وَقَدْ رَخَّصَ قَوْمٌ مِنْ أَهْلِ الْعِلْمِ فِي النَّوْمِ فِي الْمَسْجِدِ قَالَ ابْنُ عَبَّاسٍ لاَ يَتَّخِذُهُ مَبِيتًا وَلاَ مَقِيلاً وَقَوْمٌ مِنْ أَهْلِ الْعِلْمِ ذَهَبُوا إِلَى قَوْلِ ابْنِ عَبَّاسٍ