Narrated Abu Hurairah [رضی اللّٰہُ عنہ]: “The Messenger of Allah [صلی اللہ علیہ وسلم] said: “The good deeds that will reach a believer after his death are: knowledge which he learned and then spread; a righteous son whom he leaves behind; a copy of the Qur’an that he leaves as a legacy; a mosque that he built; a house that he built for wayfarers; a canal that he dug; or charity that he gave during his lifetime when he was in good health. These deeds will reach him after his death.”
[Ibn Majah: 224]