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.
nasai-kubra:10537Aḥmad b. Sulaymān > Abū Nuʿaym > Zuhayr > Abū Isḥāq > ʿĀṣim > ʿAlī

[Machine] If you take your place to sleep, say "In the name of Allah, for the sake of Allah, and on the way of the Messenger of Allah ﷺ , and when you place the deceased in his grave."  

الكبرى للنسائي:١٠٥٣٧أَخْبَرَنَا أَحْمَدُ بْنُ سُلَيْمَانَ قَالَ حَدَّثَنَا أَبُو نُعَيْمٍ عَنْ زُهَيْرٍ عَنْ أَبِي إِسْحَاقَ عَنْ عَاصِمٍ عَنْ عَلِيٍّ قَالَ

إِذَا أَخَذْتَ مَضْجَعَكَ فَقُلْ «بِاسْمِ اللهِ وَفِي سَبِيلِ اللهِ وَعَلَى مِلَّةِ رَسُولِ اللهِ ﷺ وَحِينَ تُدْخِلُ الْمَيِّتَ قَبْرَهُ»