The Messenger of Allah ﷺ said, "Keep the marriage proposal private, then perform ablution and do it well. After that, pray as much as Allah has decreed for you, then praise your Lord and glorify Him. Then say, 'O Allah, You have power and I have none, You have knowledge and I have none, and You are the Knower of all that is unseen. If You see that so-and-so,' naming her by her name, 'is good for me in my religion, my worldly life, and my hereafter, then ordain her for me. But if another is better for me than her in my religion, my worldly life, and my hereafter, then decree that for me instead.'"
أن رسول الله ﷺ قال: اكتم الخطبة، ثم توضأ فأحسن وضوءك، ثم صل ما كتب الله لك، ثم احمد ربك، ومجده ثم قل: اللهم إنك تقدر ولا أقدر، وتعلم ولا أعلم، وأنت علام الغيوب، فإن رأيت في فلانة- تسميها باسمها- خيرا لي في ديني ودنياي وآخرتي فاقدرها لي، وإن كان غيرها خيرا لي منها في ديني ودنياي وآخرتي فاقض لي ذلك.
Ahmad (23597), Ibn Khuzayma (1220), Ibn Hibban (4040), Hakim (1/314), Bayhaqi (7/147-148), and Ibn Munzir in Awsat (8/233) all narrated it through Ibn Wahb, who said that Haywa told him that Walid bin Walid informed him that Ayub bin Khalid bin Abu Ayub told him its chain and its meaning.Hakim said, "This is a rare sunnah regarding the prayer of istikhara, transmitted exclusively by the people of Egypt, and its narrators, down to the last one, are trustworthy, though the two of them did not record it."I say, the chain contains Ayub bin Khalid bin Abu Ayub Ansari, this is how he is commonly known. But Abu Ayub, the well-known companion, is not actually his grandfather. Rather, he is his maternal grandfather through Amrah, for his real grandfather was Safwan bin Aws bin Jabir Ansari. This is why Mizzi identified him by saying, "Ayub bin Khalid bin Safwan bin Aws bin Jabir Ansari Madani." And the mother of Khalid bin Safwan was Umayrah bint Abu Ayub Ansari.Its chain is hasan because of Ayub bin Khalid, who is among the narrators of Muslim and whose hadith is hasan when corroborated by other reports. His father is among the narrators mentioned in Tajil, Ibn Hibban deemed him trustworthy, and no one discredited him. He was one of the successors, and his hadith has an established basis, as mentioned earlier.There are other hadiths on this topic, see the chapter on istikhara.