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.
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."  

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

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

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

See similar narrations below:

Collected by Ibn Mājah, Aḥmad
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."  

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

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

ahmad:4607Ibn Idrīs > ʿUbaydullāh > Nāfiʿ > Ibn ʿUmar

[Machine] We used to sleep in the mosque during the time of the Prophet Muhammad ﷺ . We would stay the night and we were young.  

أحمد:٤٦٠٧حَدَّثَنَا ابْنُ إِدْرِيسَ أَخْبَرَنَا عُبَيْدُ اللهِ عَنْ نَافِعٍ عَنِ ابْنِ عُمَرَ قَالَ

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