In which literary work did Nezha first appear?

According to scholars' research, Nezha first wrote Nayi, which appeared in the Buddhist scriptures related to Vishnu in the Tang Dynasty and later. "Nezha" is a foreign phonetic name, which means that it is not native to China. It turns out that Nezha is indeed an imported name of God. He was originally a Buddhist god. Before the Tang Dynasty, there was no record of "Nezha" in China. In this way, the import of "Nezha" belongs to the Tang Dynasty, and the image as we know it today was formed after the romance of literati in later dynasties.

Guang Zhi, a monk in the Tang Dynasty, translated The Truth of Protecting the King of Vishamen in the North, calling Nezha the third son of the King of Vishamen. There are other records about Nezha in the Buddhist scriptures of the Tang Dynasty, such as "Prince Nezha, holding a halberd in his hand, seeing all directions with evil" and "Nezha, holding a pagoda and following the heavenly king" ... From these few detailed records of Buddhist scriptures, we can see something about him, such as his life experience and his role.

Due to the flourishing worship of Buddhism in the Tang Dynasty, the story of the third son of the heavenly king in Buddhist scriptures spread widely and began to become a character in the notes novels of the Tang Dynasty. For example, the Tang Xuanzong Dynasty recorded the story of Xuanlv monk Lu Yu and Nezha in the "Kai Yuan Chuan Xin Ji". This should be the earliest story of Nezha's deeds recorded in Tang Dynasty's note novels except Buddhist scriptures, but the inheritance is very obvious.