Reference : Hisn al-Muslim 165

السَّلامُ عَلَـيْكُمْ أَهْلَ الدِّيارِ مِنَ المؤْمِنيـنَ وَالْمُسْلِمين، 
وَإِنّا إِنْ شاءَ اللهُ بِكُـمْ لاحِقـون، 
نَسْـاَلُ اللهَ لنـا وَلَكُـمْ العـافِيَة
Assalāmu `alaykum ahlad-diyāri minal-mu'minīna wa ‘l-muslimīn, 
wa innā in shā' Allāhu bikum lāḥiqūn 
nas'alullāha lanā wa lakumul-`āfiyah.


Peace be upon you, people of this abode, from among the believers and those who are Muslims, 
and we, by the Will of Allah, shall be joining you. 
[May Allah have mercy on the first of us and the last of us] 
I ask Allah to grant us and you well-being.

Reference:
Muslim 2/671, Ibn Majah 1/494, the portion brackets is from Muslim 2/671.

Chapter: Visiting the graves