Narrated Jabir bin `Abdullah:As-Salami: Allah's Messenger (ﷺ) used to teach his companions to perform the prayer of Istikhara for each and every matter just as he used to teach them the Suras from the Qur'an He used to say, "If anyone of you intends to do something, he should offer a two rak`at prayer other than the compulsory prayers, and after finishing it, he should say: O Allah! I consult You, for You have all knowledge, and appeal to You to support me with Your Power and ask for Your Bounty, for You are able to do things while I am not, and You know while I do not; and You are the Knower of the Unseen. O Allah If You know It this matter (name your matter) is good for me both at present…

In the Quran

Sahih al-Bukhari 7390