The sun was eclipsed during the lifetime of the Messenger of Allah ﷺ. The Messenger of Allah ﷺ went out to the mosque, stood, and said the takbir, while the people lined up in rows behind him. The Messenger of Allah ﷺ then recited a lengthy recitation, said the takbir, and bowed for a long bowing. Then he raised his head and said, "Allah hears whoever praises Him. Our Lord, to You belongs all praise."He then stood and recited another lengthy recitation, though shorter than the first, said the takbir, and bowed for a long bowing, though shorter than the first. Then he said, "Allah hears whoever praises Him. Our Lord, to You belongs all praise."He did the same in the second rakah, completing four bowings and four prostrations. The sun had cleared before he finished.Then he stood and addressed the people. He praised Allah as He deserves to be praised, then said, "The sun and the moon are two of the signs of Allah. They do not eclipse for the death or life of anyone. So when you see them eclipse, hasten to prayer."
حدثنا أحمد بن عمرو بن السرح المصري حدثنا عبد الله بن وهب أخبرني يونس عن ابن شهاب أخبرني عروة بن الزبير
كسفت الشمس في حياة رسول الله ﷺ فخرج رسول الله ﷺ إلى المسجد فقام فكبر فصف الناس وراءه فقرأ رسول الله ﷺ قراءة طويلة ثم كبر فركع ركوعا طويلا ثم رفع رأسه فقال سمع الله لمن حمده ربنا ولك الحمد ثم قام فقرأ قراءة طويلة هي أدنى من القراءة الأولى ثم كبر فركع ركوعا طويلا هو أدنى من الركوع الأول ثم قال سمع الله لمن حمده ربنا ولك الحمد ثم فعل في الركعة الأخرى مثل ذلك فاستكمل أربع ركعات وأربع سجدات وانجلت الشمس قبل أن ينصرف ثم قام فخطب الناس فأثنى على الله بما هو أهله ثم قال إن الشمس والقمر آيتان من آيات الله لا ينكسفان لموت أحد ولا لحياته فإذا رأيتموهما فافزعوا إلى الصلاة
Bukhari reported it in the Book of Eclipses, Chapter: The Imam's Sermon During the Eclipse, no. 1046, 1212, and Muslim, in the Book of Eclipses, Chapter: The Eclipse Prayer, no. 901, from the hadith of Yunus and others, with this wording.