Burayda reported,

The Messenger of Allah ﷺ used to teach them what to say when they went out to the graveyards. The one speaking among them would say, in the narration of Abu Bakr, "Peace be upon the inhabitants of these dwellings," and in the narration of Zuhayr, "Peace be upon you, inhabitants of these dwellings, from among the believers and the Muslims. We will, Allah willing, be joining you. I ask Allah for well-being for us and for you."

Muslim 2257

Sahih

حدثنا أبو بكر بن أبي شيبة وزهير بن حرب قالا حدثنا محمد بن عبد الله الأسدي عن سفيان عن علقمة بن مرثد

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

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

مسلم 2257صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Funerals
Chapter
What is said when entering graveyards and supplicating for their inhabitants
Numbering
Darussalam 2257
Muslim 2257