The Messenger of Allah ﷺ used to go to Quba both walking and riding. Ibn Numayr added, "and he would pray two rakahs there."
حدثنا مسدد حدثنا يحيى ح حدثنا عثمان بن أبي شيبة عن ابن نمير عن عبيد الله عن نافع
أن رسول الله ﷺ كان يأتي قباء ماشيا وراكبا زاد ابن نمير ويصلي ركعتين
Muslim narrated it in the book of Hajj, chapter on the merit of Masjid Quba, the merit of praying in it, and its virtue, hadith no. 1399, from the hadith of Ibn Numayr. Bukhari narrated it in the merit of prayer in the masjid of Makkah and Madinah, chapter on going to Masjid Quba on foot or riding, hadith no. 1194, from the hadith of Ubaydullah bin Umar, through him.