Uqba bin Amir reported,

The Messenger of Allah ﷺ said, "When a man purifies himself and then proceeds to the mosque awaiting the prayer, his recording angel, or his two recording angels, writes for him ten good deeds for every step he takes toward the mosque. The one sitting awaiting the prayer is like one in devout worship, and he is counted among those praying from the moment he leaves his home until he returns."

Azami 1746

Sahih

عن عقبة بن عامر الجهني

عن رسول الله ﷺ قال: إذا تطهر الرجل ثم مر إلى المسجد يرعى الصلاة كتب له كاتبه- أو كاتباه- بكل خطوة يخطوها إلى المسجد عشر حسنات، والقاعد يرعى الصلاة كالقانت، ويكتب من المصلين من حيث يخرج من بيته حتى يرجع.

الأعظمي 1746صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Prayer
Chapter
Obligation of prayer and its virtue
Section
One waiting for prayer in the masjid being like the one in devotion
Numbering
Jami al-Kamil 1746 (2nd edition)
Azami 1746