(a) It is narrated from Sayyiduna Anas bin Malik (may Allah be pleased with him) that once the Messenger of Allah (peace and blessings be upon him) was present among us when suddenly drowsiness came over him. Then (after a while) he raised his blessed head smiling, and we said: O Messenger of Allah, what made you laugh? He said: "Just now a surah has been revealed to me." Then he (peace and blessings be upon him) began to recite: "In the name of Allah, the Most Gracious, the Most Merciful. Indeed, We have granted you al-Kawthar" [Surah al-Kawthar: 1] to the end of it. Then he mentioned the complete hadith.
(b) Several other narrators have also transmitted it with these same words, and some narrators did not mention the word 'anifan' (just now). The well-known view on this among the scholars of tafsir and maghazi is that this surah is Makkan, and the wording of the hadith of Ali bin Hujr does not contradict them; perhaps it is the better one.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 2380