Ibn Buraydah (may Allah have mercy on him) narrates from his father, Sayyiduna Buraydah (may Allah be pleased with him), that the Messenger of Allah (peace and blessings be upon him) used to say: "When they go out to the graveyard, they should say: 'As-salamu alaykum ahla al-diyari min al-mu'minina wa al-muslimin, wa inna in sha' Allahu bikum lahiqun, antum lana faratun wa nahnu lakum taba'un, nas'alu Allaha al-afiyah' (Peace be upon you, O believing and Muslim dwellers of these abodes! And surely we, if Allah wills, shall join you. You are forerunners for us and we are followers of you. We ask Allah for well-being.)"
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجنائز / 7213