Praise be to Allah.
It is better to offer naafil prayers at home, unless it is Sunnah to pray them in congregation in the mosque, such as the prayers to be offered at the time of an eclipse, or it is narrated that it is encouraged to offer them in the mosque, such as naafil prayers before Jumu’ah. That was proven from the words and actions of the Prophet (peace and blessings of Allaah be upon him). The evidence for that includes the following:
1 – It was narrated from Ibn ‘Umar that the Prophet (peace and blessings of Allaah be upon him) said: “Perform some of your prayers in your houses and do not make them graves.”
(Narrated by al-Bukhaari, 422; Muslim, 777)
The words “Perform some of your prayers in your houses and do not make them graves” mean, pray in them (your houses), and do not make them like graveyards which are devoid of prayer. What is referred to here is naafil (supererogatory) prayers, i.e., offer naafil prayers in your houses.
Sharh Muslim, 6/67
2 – It was narrated from Zayd ibn Thaabit that the Messenger of Allaah (peace and blessings of Allaah be upon him) made a cubicle – I think he said, made from a reed mat – in Ramadaan, in which he prayed at night. Some of his companions prayed behind him, and when he realized they were there he sat down. Then he went out to them and said, “I know how keen you are to pray behind me. O people, pray in your houses, for the best of prayer is a man’s prayer in his house, apart from the prescribed prayers.”
Narrated by al-Bukhaari, 698; Muslim, 781
Al-Haafiz ibn Hajar said:
The apparent meaning is that this includes all naafil prayers, because what is meant by the prescribed prayers is the obligatory prayers. But it may be interpreted as referring to all those for which it is not prescribed to offer them in congregation and those which are not to be offered specifically in the mosque, such as the two rak’ahs for “greeting the mosque.” This is the view of some of our imams.
Fath al-Baari, 2/215
3 – It was narrated that ‘Abd-Allaah ibn Shaqeeq said: I asked ‘Aa’ishah about the voluntary prayers of the Messenger of Allaah (peace and blessings of Allaah be upon him). She said: He used to pray four rak’ahs before Zuhr in my house, then he would go out and lead the people in prayer, then he would come in and pray two rak’ahs. And he used to lead the people in Maghrib prayer, then he would come in and pray two rak’ahs. And he would lead the people in praying ‘Isha’, then he would come into my house and pray two rak’ahs. And he would pray nine rak’ahs of night prayer (qiyaam al-layl), including Witr. He would pray long prayers at night standing and long prayers at night sitting. If he recited Qur’aan standing, he would bow and prostrate from a standing position and if he recited Qur’aan whilst sitting he would bow and prostrate from a sitting position. Wand when dawn came he would pray two rak’ahs.
Narrated by Muslim. 730; there is a similar hadeeth narrated from Ibn ‘Umar in al-Saheehayn.
Al-Nawawi said in his commentary:
This indicates that it is mustahabb to offer the regular naafil prayers in one's house, as is also the case with other naafil prayers. There is no difference of opinion among us on this point. This is the view of the majority and in our view and theirs, the naafil prayers connected to the obligatory prayers are the same whether they are done at night or during the day.
Sharh Muslim, 6/9
4 – It was narrated that Jaabir said: The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “When any one of you finishes his prayer in his mosque, let him give his house a share of his prayer, for Allaah will create something good in his house from his prayer.”
Narrated by Muslim, 778
The phrase “When any one of you finishes his prayer in his mosque” means, performing the obligatory prayer in a place where it is offered in congregation. The mosque is mentioned because that is where the prayer is usually held. “Let him give his house” means the place where he lives. “A share” means a portion. “Of his prayer” means, let him do the obligatory prayers in the mosque and the naafil prayers in his house, to bring barakah (blessing) upon his house and family, as he says, “for Allaah will create something good in his house from his prayer”, i.e., because of the prayer. “Something good” means a great deal of good, because he has furnished his house with the remembrance and obedience of Allaah, and the presence and glad tidings of the angels, and the reward and barakah that he brings to his family.
It also indicates that naafil prayers offered at home are better than those offered in the mosque, even in al-Masjid al-Haraam.
Fayd al-Qadeer, 1/418
There is more evidence than this, for the regular naafil prayers of the Prophet (peace and blessings of Allaah be upon him), his night prayers (qiyaam al-layl) and Duha prayer were all done in his house, but we have omitted (the reports concerning) that for the sake of brevity. What we have mentioned above is sufficient. Some of the scholars have stated that there is a reason for that:
Ibn Qudaamah said:
Offering voluntary prayers at home is preferable, because praying at home is closer to sincerity and furthest removed from showing off. It is an act that is done in secret, whereas doing it is the mosque is in public, and secrecy is better.
It also serves as a reminder to the forgetful and teaching of the ignorant among the members of the household or those who see him.
With regard to the evidence that it is mustahabb to offer the eclipse prayer in the mosque:
5 – It was narrated that Abu Bakrah said: We were with the Messenger of Allaah (peace and blessings of Allaah be upon him) when the sun was eclipsed. The Prophet (peace and blessings of Allaah be upon him) got up, dragging his lower garment, and entered the mosque. We entered too, and he led us in praying two rak’ahs until the sun had cleared. Then he (peace and blessings of Allaah be upon him) said: “The sun and the moon do not become eclipsed for the death of anyone. If you see that then pray and make du’aa’ until the eclipse is over.”
Narrated by al-Bukhaari, 993
With regard to the evidence that it is mustahabb to offer the naafil prayers before Jumu’ah in the mosque:
6 – It was narrated that Salmaan al-Farsi said: The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Whoever does ghusl on a Friday and purifies himself as much as he can, then puts oil (on his hair) and applies perfume, and does not force his way between two persons (assembled in the mosque for the Friday prayer), then prays as much has been decreed for him, then keeps quiet when the imam comes out (to deliver the khutbah), his sins between that Friday and the previous one will be forgiven.”
Narrated by al-Bukhaari, 868
And Allaah knows best.