Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:3:157

And if you are killed in the cause of Allah or die - then forgiveness from Allah and mercy are better than whatever they accumulate ˹in this world˺.  

And if (wa-la-in, the lām is for oaths) you are slain in God’s way, in ˹holy˺ struggle, or die (read muttum or mittum, from ˹singular form˺ māta, yamūtu), that is, if death comes to you thereat, forgiveness, that is, from God, for your sins, and mercy, therefor from Him for you (the clause introduced by the lām ˹of lamaghfiratun, ‘forgiveness’˺ is the response to the oath ˹clause of la’in˺, and occupies the place of the verbal action as a subject, the predicate of which ˹is what follows˺) are better than what they amass, in this world (read tajma‘ūn, ‘you amass’, or yajma‘ūn, ‘they amass’).
القرآن:٣:١٥٧

وَلَئِنْ قُتِلْتُمْ فِي سَبِيلِ اللَّهِ أَوْ مُتُّمْ لَمَغْفِرَةٌ مِنَ اللَّهِ وَرَحْمَةٌ خَيْرٌ مِمَّا يَجْمَعُونَ  

{ولئن} لام قسم {قُتِلْتُمْ في سبيل الله} أي الجهاد {أو مُتُّمْ} بضم الميم وكسرها من مات يموت أي أتاكم الموت فيه {لمغفرة} كائنة {من الله} لذنوبكم {ورحمة} منه لكم على ذلك واللام ومدخولها جواب القسم وهو في موضوع الفعل مبتدأ خبره {خير مما تجمعون} من الدنيا بالتاء والياء.