USC-MSA web (English) : Book 16, Hadith 42
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
وَحَدَّثَنِي عَنْ مَالِكٍ، عَنْ رَبِيعَةَ بْنِ أَبِي عَبْدِ الرَّحْمَنِ، عَنْ أُمِّ سَلَمَةَ، زَوْجِ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ، أَنَّ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ قَالَ مَنْ أَصَابَتْهُ مُصِيبَةٌ فَقَالَ كَمَا أَمَرَ اللَّهُ (إِنَّا لِلَّهِ وَإِنَّا إِلَيْهِ رَاجِعُونَ) اللَّهُمَّ أْجُرْنِي فِي مُصِيبَتِي وَأَعْقِبْنِي خَيْرًا مِنْهَا إِلَّا فَعَلَ اللَّهُ ذَلِكَ بِهِ قَالَتْ أُمُّ سَلَمَةَ فَلَمَّا تُوُفِّيَ أَبُو سَلَمَةَ قُلْتُ ذَلِكَ ثُمَّ قُلْتُ وَمَنْ خَيْرٌ مِنْ أَبِي سَلَمَةَ فَأَعْقَبَهَا اللَّهُ رَسُولَهُ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ فَتَزَوَّجَهَا
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 (ﷺ) 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 (ﷺ) and he married her.
Full reference and source
USC-MSA web (English) : Book 16, Hadith 42 Arabic : Book 16, Hadith 564
View source on Sunnah.com (opens in a new tab)