Usama bin Zayd reported,

We were with the Prophet ﷺ when a messenger from one of his daughters came calling him to her son who was dying.The Prophet ﷺ said, "Go back to her and tell her that to Allah belongs what He takes and to Him belongs what He gives, and everything with Him has an appointed term. So instruct her to be patient and to seek her reward from Allah."The messenger returned saying that she had sworn that he must come to her. So the Prophet ﷺ got up, and Saad bin Ubada and Muaz bin Jabal got up with him. The child was handed to him, his soul rattling as if it were in a worn-out waterskin, and the Prophet's eyes overflowed with tears.Saad said to him, "Messenger of Allah, what is this?"He replied, "This is mercy that Allah has placed in the hearts of His servants. Allah shows mercy only to those of His servants who are merciful."

Azami 11102

Sahih

عن أسامة بن زيد قال

كنا عند النبي ﷺ إذ جاءه رسول إحدى بناته يدعوه إلى ابنها في الموت. فقال النبي ﷺ: ارجع إليها، فأخبرها أن الله ما أخذ، وله ما أعطى، وكل شيء عنده بأجل مسمى، فمرها فلتصبر ولتحتسب فأعادت الرسول أنها قد أقسمت لتأتينها، فقام النبي ﷺ وقام معه سعد بن عبادة ومعاذ بن جبل، فدفع الصبي إليه ونفسه تقعقع كأنها في شن، ففاضت عيناه فقال له سعد: يا رسول الله ما هذا؟ قال: هذه رحمة جعلها الله في قلوب عباده، وإنما يرحم الله من عباده الرحماء.

الأعظمي 11102صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Supplications, remembrances, and prayer upon the chosen Prophet ﷺ
Chapter
Supplications for illness and funerals, and what relates to them
Section
What is said in offering condolences
Numbering
Jami al-Kamil 11102 (2nd edition)
Azami 11102