Al-Ilmam bi-Ahadith al-Ahkam 472
وَعَن سُلَيْمَان بن بُريدة، عَن أَبِيه، قَالَ: كَانَ رَسُول الله ﷺ يعلمهُمْ إِذا خَرجُوا إِلَى الْمَقَابِر، فَفِي رِوَايَة: " السَّلَام عَلَى أهل الديار ". وَفِي رِوَايَة: " السَّلَام عَلَيْكُم أهل الديار من الْمُؤمنِينَ وَالْمُسْلِمين وَالْمُسلمَات وَإِنَّا إِن شَاءَ الله بكم للاحقون. أسأَل الله لنا وَلكم الْعَافِيَة ". أخرجه مُسلم. وَزَاد الْبَيْهَقِيّ فِي رِوَايَة لَهُ فِي حَدِيث سُلَيْمَان: " أَنْتُم لنا فرط، وَنحن لكم تبع، نسْأَل الله لكم الْعَافِيَة ".
And from Sulayman ibn Buraydah, from his father, who said: The Messenger of Allah ﷺ used to teach them [what to say] when they went out to the graveyards. In a narration: "Peace be upon the people of the dwellings." And in a narration: "Peace be upon you, people of the dwellings, among the believers and the Muslims, men and women, and we, if Allah wills, will join you. I ask Allah for well-being for us and for you." Muslim recorded it. And al-Bayhaqi added in a narration of his, in the hadith of Sulayman: "You have gone ahead of us and we will follow you. We ask Allah for well-being for you."