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:21:89

And ˹mention˺ Zechariah, when he called to his Lord, "My Lord, do not leave me alone ˹with no heir˺, while you are the best of inheritors."  

And, mention, Zachariah (Zakariyyā, is substituted by ˹the following, idh nādā rabbahu …˺) when he cried out to his Lord, saying: ‘My Lord, do not leave me without an heir, without a son to inherit from me, and You are the best of inheritors’, the One that endures after all of your creation has perished.
القرآن:٢١:٨٩

وَزَكَرِيَّا إِذْ نَادَىٰ رَبَّهُ رَبِّ لَا تَذَرْنِي فَرْدًا وَأَنْتَ خَيْرُ الْوَارِثِينَ  

{و} اذكر {زكريا} ويبدل منه {إذ نادى ربه} بقوله {رب لا تذرني فرداً} أي بلا ولد يرثني {وأنت خير الوارثين} الباقي بعد فناء خلقك.