Hadithcore
Riyad as-Salihin, 135

Jabir (May Allah be pleased with him) reported:

Messenger of Allah (ﷺ) said, "When a Muslim plants a tree, whatever is eaten from it is charity from him and whatever is stolen is charity and whatever is subtracted from it is charity". <b>[Muslim]</b>. Another narration says: "If a Muslim plants a tree, or sows a field and men and beasts and birds eat from it, all of it is charity from him".

التاسع عشر‏:‏ عنه قال‏:‏ قال رسول الله صلى الله عليه وسلم‏:‏ ‏"‏ ما من مسلم يغرس غرساً إلا كان ما أكل منه له صدقة، وما سرق منه له صدقة، ولا يرزؤه أحد إلا كان له صدقة‏"‏ ‏(‏‏(‏رواه مسلم‏.‏ ‏)‏‏)‏ وفي رواية له‏:‏ ‏"‏ فلا يغرس المسلم غرساً، فيأكل منه إنسان ولا دابة ولا طير إلا كان له صدقة إلى يوم القيامة‏"‏‏.‏ وفي رواية له‏:‏ ‏"‏ لا يغرس مسلم غرساً، ولا يزرع زرعاً، فيأكل منه إنسان ولا دابة ولا شىء إلا كانت له صدقة‏"‏ وروياه جميعاً من رواية أنس رضي الله عنه‏.‏

References1 variant
In-Book Reference
Introduction, Hadith 135
Sharh · explanationclick to expand
<b>Guidance from the Hadith:</b><br> 1) It urges planting trees and plants due to the religious and worldly benefits this involves.<br> 2) It shows the abundant and diverse means of good deeds.<br> 3) Establishing public services benefits its founder when people make use of it, even if the founder had not intended so. If he intended to benefit people thereby, his reward will be multiplied; {Anyone who does that, seeking Allah’s pleasure, We will give him a great reward.} [Surat an-Nisā’: 114]