The Messenger of Allah ﷺ said, "When any of you is struck by a calamity, let him say, 'Indeed, we belong to Allah, and to Him we shall return. O Allah, with You I seek the reward for my calamity, so reward me for it and replace it for me with something better.'"When Abu Salama was on his deathbed, he said, "O Allah, leave behind in my family someone better than me."When he passed away, Umm Salama said, "Indeed, we belong to Allah, and to Him we shall return. With Allah I seek the reward for my calamity, so reward me for it."
حدثنا إبراهيم بن يعقوب حدثنا عمرو بن عاصم حدثنا حماد بن سلمة عن ثابت عن عمر بن أبي سلمة عن أمه أم سلمة
أن رسول الله ﷺ قال إذا أصاب أحدكم مصيبة فليقل إنا لله وإنا إليه راجعون اللهم عندك احتسبت مصيبتي فأجرني فيها وأبدلني منها خيرا فلما احتضر أبو سلمة قال اللهم اخلف في أهلي خيرا مني فلما قبض قالت أم سلمة إنا لله وإنا إليه راجعون عند الله احتسبت مصيبتي فأجرني فيها
Grading, its isnad is hasan. Nasai also reported it in Amal al-Yawm wal-Layla, no. 1070, from the hadith of Hammad bin Salama, through the same route. Ibn Majah reported it, no. 1598, from the hadith of Umar bin Abu Salama. There is another route for it in Ahmad, 6/27.