The Messenger of Allah ﷺ used to teach them what to say when they went out to the graveyards. The one who spoke 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, Allah willing, shall be joining you. I ask Allah for well-being for us and for you."
كان رسول الله ﷺ يعلمهم إذا خرجوا إلى المقابر، فكان قائلهم يقول ( في رواية أبي بكر): السلام على أهل الديار، ( وفي رواية زهير): السلام عليكم أهل الديار من المؤمنين والمسلمين، وإنا إن شاء الله للاحقون، أسأل الله لنا العافية.
Muslim reported it in the Book of Funerals (975), on the authority of Abu Bakr bin Abu Shayba and Zuhayr bin Harb, who said, Muhammad bin Abdullah Asadi told us, from Sufyan, from Alqama bin Marthad, from Sulayman bin Burayda, from his father, and he related it.Nasai (2040) added, after the words "we will surely join you," "You are our forerunners, and we will follow you. I ask Allah for well-being for us and for you."