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:28:7

And We inspired to the mother of Moses, "Suckle him; but when you fear for him, cast him into the river and do not fear and do not grieve. Indeed, We will return him to you and will make him ˹one˺ of the messengers."  

And We revealed, by inspiration or in a dream, to the mother of Moses — who was the said new-born; his sister was the only other person aware of his birth — ‘Suckle him, then, when you fear for him, cast him into the waters, namely, the Nile, and do not fear, that he should drown, or grieve, for being separated from him, for We will restore him to you and make him one of the messengers’. She suckled him for three months during which he never cried. She then began to fear for him and so she placed him in a basket coated with pitch and made as a cradle for him on the inside. She then closed it and cast it into the waters of the Nile at night.
القرآن:٢٨:٧

وَأَوْحَيْنَا إِلَىٰ أُمِّ مُوسَىٰ أَنْ أَرْضِعِيهِ ۖ فَإِذَا خِفْتِ عَلَيْهِ فَأَلْقِيهِ فِي الْيَمِّ وَلَا تَخَافِي وَلَا تَحْزَنِي ۖ إِنَّا رَادُّوهُ إِلَيْكِ وَجَاعِلُوهُ مِنَ الْمُرْسَلِينَ  

{وأوحينا} وحي إلهام أو منام {إلى أم موسى} وهو المولود المذكور ولم يشعر بولادته غير أخته {أن أرضعيه فإذا خفت عليه فألقيه في اليم} البحر أي النيل {ولا تخافي} غرقه {ولا تحزني} لفراقه {إنا رادوه إليك وجاعلوه من المرسلين} فأرضعته ثلاثة أشهر لا يبكي وخافت عليه فوضعته في تابوت مطليٍّ بالقار من داخل ممهد له فيه وأغلقته وألقته في بحر النيل ليلاً.