Sunan Ibn Majah, Book 1, Hadith 249 (In-Book) ⓘ
It was narrated that Abu Hurairah said: "The Messenger of Allah said: 'The rewards of the good deeds that will reach a believer after his death are: Knowledge which he taught and 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.'"
حَدَّثَنَا مُحَمَّدُ بْنُ يَحْيَى، حَدَّثَنَا مُحَمَّدُ بْنُ وَهْبِ بْنِ عَطِيَّةَ، حَدَّثَنَا الْوَلِيدُ بْنُ مُسْلِمٍ، حَدَّثَنَا مَرْزُوقُ بْنُ أَبِي الْهُذَيْلِ، حَدَّثَنِي الزُّهْرِيُّ، حَدَّثَنِي أَبُو عَبْدِ اللَّهِ الأَغَرُّ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ ـ صلى الله عليه وسلم ـ " إِنَّ مِمَّا يَلْحَقُ الْمُؤْمِنَ مِنْ عَمَلِهِ وَحَسَنَاتِهِ بَعْدَ مَوْتِهِ عِلْمًا عَلَّمَهُ وَنَشَرَهُ وَوَلَدًا صَالِحًا تَرَكَهُ وَمُصْحَفًا وَرَّثَهُ أَوْ مَسْجِدًا بَنَاهُ أَوْ بَيْتًا لاِبْنِ السَّبِيلِ بَنَاهُ أَوْ نَهْرًا أَجْرَاهُ أَوْ صَدَقَةً أَخْرَجَهَا مِنْ مَالِهِ فِي صِحَّتِهِ وَحَيَاتِهِ يَلْحَقُهُ مِنْ بَعْدِ مَوْتِهِ " .
also referenced under: Hadith 242 (Reference) & Volume 1, Book 1, Hadith 242 (DarusSalam)