Muwatta Malik, Book 16, Hadith 42 (USC-MSA)

Yahya related to me from Malik from Rabia ibn Abi Abd ar-Rahman from Umm Salama, the wife of the Prophet may Allah bless him and grant him peace, that the Messenger of Allah, may Allah bless him and grant him peace, said, "If a misfortune befalls some one and he says, as Allah has ordered, 'We belong to Allah and to Him we are returning. O Allah, reward me in my misfortune and give me better than it afterwards,' Allah will do that for him" (Inna lillahi wa inna ilayhi rajiun. Allahumma' jurniy fi musiybatiy, wa a qibhiy khayran minha, illa faala 'llahu dhalika bihi.). Umm Salama said, "When Abu Salama died I said that, and then I said, 'Who is better than Abu Salama?' " And then Allah left her the Messenger of Allah, may Allah bless him and grant him peace, and he married her.

وَحَدَّثَنِي عَنْ مَالِكٍ، عَنْ رَبِيعَةَ بْنِ أَبِي عَبْدِ الرَّحْمَنِ، عَنْ أُمِّ سَلَمَةَ، زَوْجِ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ، أَنَّ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ قَالَ مَنْ أَصَابَتْهُ مُصِيبَةٌ فَقَالَ كَمَا أَمَرَ اللَّهُ (إِنَّا لِلَّهِ وَإِنَّا إِلَيْهِ رَاجِعُونَ) اللَّهُمَّ أْجُرْنِي فِي مُصِيبَتِي وَأَعْقِبْنِي خَيْرًا مِنْهَا إِلَّا فَعَلَ اللَّهُ ذَلِكَ بِهِ قَالَتْ أُمُّ سَلَمَةَ فَلَمَّا تُوُفِّيَ أَبُو سَلَمَةَ قُلْتُ ذَلِكَ ثُمَّ قُلْتُ وَمَنْ خَيْرٌ مِنْ أَبِي سَلَمَةَ فَأَعْقَبَهَا اللَّهُ رَسُولَهُ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ فَتَزَوَّجَهَا

sunnah.com

also referenced under: Book 16, Hadith 564 (In-Book)