(4) باب جَوَازِ صَلاَةِ النَّافِلَةِ عَلَى الدَّابَّةِ فِي السَّفَرِ حَيْثُ تَوَجَّهَتْ
Ibn 'Umar reported that the Messenger of Allah (ﷺ) used to say prayer on his camel while coming from Mecca to Medina, in whatever direction his face had turned; and its was (in this context) that this verse was revealed:
" So whether you turn thither is Allah's face" (ii. 115).
Reference: Sahih Muslim 700 c
In-book reference: Book 6, Hadith 43
USC-MSA web (English) reference(deprecated numbering scheme): Book 4, Hadith 1499