The Prophet ﷺ used to observe itikaf during the last ten days of Ramadan until Allah took his soul, and his wives observed itikaf after him.
إن النبي ﷺ كان يعتكف العشر الأواخر من رمضان حتى توفاه الله، ثم اعتكف أزواجه من بعده.
Bukhari narrated it in the Book of Itikaf (2026), and Muslim narrated it in the Book of Itikaf (1172:5), both of them through the route of Layth bin Saad, from Aqeel, from Ibn Shihab Zuhri, from Urwa bin Zubayr, from Ayesha, and I have mentioned it, and their wording is identical.Her statement, "Then his wives observed itikaf after him," means they observed itikaf in the masjids, since it is established in Sahih Muslim (297) that she said, "I used to enter the house to attend to a need while a sick person was in it, and I would only ask about him while passing through." Her statement, "I used to enter the house," is evidence that she used to observe itikaf in the masjid.