Imaam Muhammad Ibn Saalih al-’Uthaymeen (d.1421H) – rahimahullaah – said,
“And from spending the wealth in the ways of goodness is: that the individual spends in the building of masaajid, either exclusively or by co-operating and participating along with others. So it has been authentically narrated from the Prophet (sallallaahu ’alayhi wa sallam) that he said, “Whosoever builds a masjid for Allaah, seeking thereby the Face of Allaah, then Allaah will build a house for him in Paradise.” 
So the Muslims pray in the masaajid and those who are in need seek shelter therein. And the remembrance of Allaah is performed in them by recitation of the Qur‘aan and the Sunnah of His Messenger (sallallaahu ’alayhi wa sallam). And the fiqh (understanding) of the Religion is taught. And in all of that is a reward for the one who built that masjid or participated in its establishment.
And from spending wealth in the ways of good is: that the individual spends in the publication or beneficial books and specific publications or that he buys them and distributes them to those who will benefit from them.”
: Related by al-Bukhaaree (no. 450) and Muslim (no. 533), from the hadeeth of ’Uthmaan Ibn ’Affaan (radiyallaahu ’anhu).
Translation by Maaz Qureshi