Mishkat al-Masabih

Buraida said that God's messenger used to teach them to say when they went out to the cemeteries, “Peace be upon you, inhabitants of the dwellings who are of the number of the believers and the Muslims. If God will, we shall join you. We ask God to grant us and you wellbeing.” Muslim transmitted it.

وَعَنْ بُرَيْدَةَ قَالَ: كَانَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ يُعَلِّمُهُمْ إِذَا خَرَجُوا إِلَى الْمَقَابِرِ: «السَّلَامُ عَلَيْكُمْ أَهْلَ الدِّيَارِ مِنَ الْمُؤْمِنِينَ وَالْمُسْلِمِينَ وَإِنَّا إِنْ شَاءَ اللَّهُ بِكُمْ لَلَاحِقُونَ نَسْأَلُ اللَّهَ لَنَا وَلَكُمُ الْعَافِيَةَ» . رَوَاهُ مُسْلِمٌ