I've written a step-by-step tutorial on how to build an AI chat app with Next.js, TypeScript, TailwindCSS, and then OpenAI API.
If you instead want to jump straight into the code, you can find the repository here: https://github.com/jakeprins/nextjs-chatgpt-tutorial