Pixel-styled Next.js chat UI that sends your prompt to OpenAI and renders the reply with proper Markdown.
- Client (
app/page.tsx) posts your message to/api/chat, keeps local state, and renders replies withreact-markdown+remark-gfmso headings, lists, and emphasis display correctly. - Server route (
app/api/chat/route.ts) runs on the Edge runtime, callsopenai.chat.completions.createwithgpt-4o-mini, and returns the first message content. - Styling: Tailwind dark theme, pixelated title via
Press_Start_2Pfont, base fonts from Geist inapp/layout.tsx.
- Node 18+.
OPENAI_API_KEYin your environment.
- Install deps:
npm install - Export your key:
export OPENAI_API_KEY=... - Start dev server:
npm run devand openhttp://localhost:3000
- Build:
npm run build(Next.js 16.1.1). - Deploy: works on Vercel; ensure the
OPENAI_API_KEYenv var is set in your hosting environment.
- Change the model or system prompt in
app/api/chat/route.ts. - Tweak the Markdown styling or add more MD elements in the
ReactMarkdowncomponentsmap inapp/page.tsx.