Solar and lunar eclipse prayers are confirmed sunnas.
Aisha (G. p. H) narrated that the Prophet (P. B. U. H) said:
"The sun and the moon are two signs amongst the signs of Allah.
They do not eclipse because of the death or birth of anyone (The Prophet (P. B. U. H) said that after it was rumored that the sun suffered an eclipse for the death of his son Ibrahim).
So when you witness such an event, invoke Allah, pronounce takbir,0 and pray..".
[Al-Bukhari, Vol. 1, The Book of Eclipse, Chapter 2/997].
Also, Allah (G. B. H) says:
{Adore not the sun and the moon, but adore Allah, Who created them. It is He you wish to serve} [Fussilat: 37]. (pa: 199)
It is valid to perform the eclipse prayer individually, but it is recommended to perform it in congregation, and to call for it by announcing:
"The prayer is gathering".
Abdullah ibn Amr (G. p. H) said: "When the sun went into eclipse at the time of the Messenger of Allah (P. B. U. H), an announcement was made: The prayer is gathering. '"
[Al-Bukhari, Vol. 1, The Book of Eclipse, Chapter 3/998].
It is valid for one who has performed an eclipse prayer alone, to repeat it behind the imam if he catches up with him, just as is done in prescribed prayers.
It is recommended to do ghusl for it because it is a prayer for which both a congregation and a khutba are prescribed, just like the Friday prayer.