Sunan Ibn Majah 1547
It was narrated from Sulaiman bin Buraidah that his father said:
“The Messenger of Allah ﷺ used to teach them, when they went out to the graveyard, to say: As-salamu ‘alaykum ahlad-diyar minal-mu’minina wal- muslimin, wa inna insha’ Allah bikum lahiqun, nas’alul-laha lana wa lakumul-‘afiyah (Peace be upon you, O inhabitants of the abodes, believers and Muslims, and we will join you soon if Allah wills. We ask Allah for well-being for us and for you).’”
حَدَّثَنَا مُحَمَّدُ بْنُ عَبَّادِ بْنِ آدَمَ، حَدَّثَنَا أَبُو أَحْمَدَ، حَدَّثَنَا سُفْيَانُ، عَنْ عَلْقَمَةَ بْنِ مَرْثَدٍ، عَنْ سُلَيْمَانَ بْنِ بُرَيْدَةَ، عَنْ أَبِيهِ، قَالَ كَانَ رَسُولُ اللَّهِ ﷺ يُعَلِّمُهُمْ إِذَا خَرَجُوا إِلَى الْمَقَابِرِ كَانَ قَائِلُهُمْ يَقُولُ السَّلاَمُ عَلَيْكُمْ أَهْلَ الدِّيَارِ مِنَ الْمُؤْمِنِينَ وَالْمُسْلِمِينَ وَإِنَّا إِنْ شَاءَ اللَّهُ بِكُمْ لاَحِقُونَ نَسْأَلُ اللَّهَ لَنَا وَلَكُمُ الْعَافِيَةَ .