Burayda reported,

The Messenger of Allah ﷺ used to teach them, when they went out to the graveyards, that their spokesman should say, "Peace be upon you, people of these dwellings, from among the believers and the Muslims. We will, Allah willing, be joining you. We ask Allah for well-being for us and for you."

Ibn Majah 1547

Sahih

حدثنا محمد بن عباد بن آدم حدثنا أحمد حدثنا سفيان عن علقمة بن مرثد

عن سليمان بن بريدة عن أبيه قال

كان رسول الله ﷺ يعلمهم إذا خرجوا إلى المقابر كان قائلهم يقول السلام عليكم أهل الديار من المؤمنين والمسلمين وإنا إن شاء الله بكم لاحقون نسأل الله لنا ولكم العافية

ابن ماجه 1547صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Funerals
Chapter
What is said when entering the graveyard
Numbering
Darussalam 1547
Ibn Majah 1547