A quick note that Istikharah (the prayer of seeking guidance) can be done anywhere, at any time.
There are three variations to consider:
1) Prayer and the long du’a
This is the optimal way and the sunnah. A 2 rak’ah prayer followed by the well-known du’a we normally recite (the full du’a is below).
2) The long du’a only
This is in cases you can’t physically pray. Like recently, I was in the car and had to make an important decision. There’s no harm in these cases just to recite the du’a and still feel it is valid.
Imam al-Nawawi allows this concession in his book on supplications (Al-Adhkar):
ولو تعذرت عليه الصلاة استخار بالدعاء
‘If the prayer is not possible, then he may supplicate with Istikhara (itself)’.
3) Short du’a only
This is for those quick decisions. You can’t pray and you want to say a brief du’a, relegating your affair to Allah.
One may say;
اللهُّمَ خِر لِي وَاختَر لِي
‘O Allah! Grant me goodness and select the better option for me’ (Tirmidhi).
—
The optimal of the three above is the first with the prayer. Why?
The scholar Ibn Abi Jamrah mentions the wisdom of the prayer before the du’a is that;
“The purpose of Istikharah is to attain the benefit of this world and the hereafter in unison. This requires knocking on the door of the Sovereign (Allah)…
(Istikhara Du’a – https://ahadith.co.uk/hisnulmuslim-dua-26)