Sunan an-Nasa'i, Book 21, Hadith 224 (In-Book)

It was narrated from Sulaiman bin Buraidah, from his father, that: when the Messenger of Allah came to the graveyard he would say: "As-salamu 'alaykum ahli ad-diyari min al-mu'minin wal-muslimin wa inna I sha' Allahu bikum lana faratun wa nahnu lakum taba'un, as'alullahal-'afiyata lana wa lakum. (Peace by upon the inhabitants of this place among the believers and Muslims. Soon we will join you, if Allah willing. You have gone on ahead of us and we will follow you. I ask Allah to keep us and you safe and sound.)"

أَخْبَرَنَا عُبَيْدُ اللَّهِ بْنُ سَعِيدٍ، قَالَ حَدَّثَنَا حَرَمِيُّ بْنُ عُمَارَةَ، قَالَ حَدَّثَنَا شُعْبَةُ، عَنْ عَلْقَمَةَ بْنِ مَرْثَدٍ، عَنْ سُلَيْمَانَ بْنِ بُرَيْدَةَ، عَنْ أَبِيهِ، ‏:‏ أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم كَانَ إِذَا أَتَى عَلَى الْمَقَابِرِ فَقَالَ ‏:‏ ‏ "‏ السَّلاَمُ عَلَيْكُمْ أَهْلَ الدِّيَارِ مِنَ الْمُؤْمِنِينَ وَالْمُسْلِمِينَ، وَإِنَّا إِنْ شَاءَ اللَّهُ بِكُمْ لاَحِقُونَ، أَنْتُمْ لَنَا فَرَطٌ وَنَحْنُ لَكُمْ تَبَعٌ، أَسْأَلُ اللَّهَ الْعَافِيَةَ لَنَا وَلَكُمْ ‏" ‏ ‏.‏

sunnah.com