Ayesha reported,

I asked the Messenger of Allah ﷺ about the plague, and he informed me that it is a punishment which Allah sends upon whomever He wills, but that Allah has made it a mercy for the believers. There is no one who, when the plague strikes, remains in his town patiently and seeking reward, knowing that nothing will befall him except what Allah has decreed for him, except that he will receive a reward like that of a martyr.

Bukhari 3474

Sahih

حدثنا موسى بن إسماعيل حدثنا داود بن أبي الفرات حدثنا عبد الله بن بريدة عن يحيى بن يعمر

عن عائشة رضي الله عنها زوج النبي ﷺ قالت

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

البخاري 3474صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Hadiths of the prophets
Chapter
Hadith of the cave
Numbering
Darussalam 3474
Bukhari 3474