The Prophet ﷺ, when he woke up, would say, "Praise be to Allah who has brought us back to life after causing us to die, and to Him is the resurrection."Shuba said, "This, or something close to this meaning."And when he went to sleep, he would say, "O Allah, in Your name I live and in Your name I die."
حدثنا حجاج أخبرنا شعبة عن عبد الله بن أبي السفر قال سمعت أبا بكر بن أبي موسى يحدث
أن النبي ﷺ كان إذا استيقظ قال الحمد لله الذي أحيانا بعدما أماتنا وإليه النشور قال شعبة هذا أو نحو هذا المعنى وإذا نام قال اللهم باسمك أحيا وباسمك أموت
Its chain of transmission is sahih. The hadith is well-known and was narrated by Bukhari 8/85, Shab edition, in the Book of Supplications, chapter on what to say when going to sleep, and by Muslim 4/2083, number 2711, in the Book of Remembrance, chapter on what to say at sleep.