nextjs-chatbot
Skill72 starsChanged 17 days agoMITView on GitHub
Production Next.js web-chat integration: tool approval, persisted conversations, tool result UI, grounded retrieval, follow-up suggestions and embedded widgets. Use when building or debugging a web chatbot that needs these features. Use nextjs-shadcn for scaffolding and ai-sdk for general SDK APIs; multi-platform bots use Chat SDK.
In this repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/ai-sdk-6/references/agents.mdAGENTS.md
- skills/ai-sdk-7/references/agents.mdAGENTS.md
- skills/openai-agents-sdk/references/agents.mdAGENTS.md
- skills/react-best-practices/AGENTS.mdAGENTS.md
- skills/vercel-react-view-transitions/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-harness-reviewSkill
- ai-appSkill
- ai-elementsSkill
- ai-sdk-6Skill
- ai-sdk-7Skill
- ai-sdkSkill
- cache-componentsSkill
- chrome-devtoolsSkill
- frontend-designSkill
- goSkill
- handoffSkill
- hetzner-cloudSkill
- iconsSkill
- next-best-practicesSkill
- nextjs-seoSkill
- nextjs-shadcnSkill
- openai-agents-sdkSkill
- postgres-semantic-searchSkill
- react-best-practicesSkill
- shadcnSkill
- supabase-postgres-best-practicesSkill
- vercel-react-view-transitionsSkill
- web-design-guidelinesSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Use this skill for web-chat integration: persisted conversations, tool approval, tool result UI and an embedded widget.
- Distinctive: line 16
Keep the project's stack. Choose the model, reasoning setting, storage and client state from the product's quality, latency and privacy …
- Very specific: line 25
Read the installed node_modules/ai/docs/04-ai-sdk-ui/ for persistence, tool usage, errors and resume streams.
- Very specific: line 33
Use ai-sdk-7 for v7 and ai-sdk-6 for existing v6 projects.
- Very specific: line 51
Verify actual proxy streaming and buffering configuration.
- Very specific: line 59
Keep the answer, relevant tool results and useful sources readable.
- Distinctive: line 67
Follow streamed output while the reader is at the bottom.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Production Next.js chatbots
Use this skill for web-chat integration: persisted conversations, tool approval,
tool result UI and an embedded widget. Use nextjs-shadcn for scaffolding,
ai-sdk to resolve the SDK version, and the shadcn skill for chat components.
An existing elements.ai-sdk.dev install keeps its copied source in
components/ai-elements/ as the reference until it migrates (deprecated upstream
at the end of November 2026; see https://ui.shadcn.com/docs/ai-elements).
For multi-platform messaging, consult Chat SDK.
Keep the project's stack. Choose the model, reasoning setting, storage and client state from the product's quality, latency and privacy requirements. A chatbot does not inherently need PostgreSQL, Zustand, MCP servers or every message action. When a new project has not decided, the defaults are Bun, the AI Elements patterns from shadcn/ui (Message, Bubble, Message Scroller, Trace; https://ui.shadcn.com/docs/ai-elements), Drizzle + PostgreSQL for server-side history, and a fast model with low or no reasoning effort, because chat latency is the product.
Read the installed node_modules/ai/docs/04-ai-sdk-ui/ for persistence, tool
usage, errors and resume streams; use the package's types and src/ when
shipped for exact contracts.
The linked ai-sdk.dev pages are the online fallback and describe the newest major.
Integration contracts
- Match
ai,@ai-sdk/reactand provider versions before writing API calls. Useai-sdk-7for v7 andai-sdk-6for existing v6 projects; core callback renames do not imply renaming the separateuseChat.onFinish. - Authenticate conversation access, validate request data and authorize tools on the server. Client history, context, model IDs and consent flags are untrusted; prompts cannot enforce tenant isolation or permissions.
- Store validated UI messages with stable IDs when the full conversation UI must be restored. Convert model history through the installed SDK's helpers; keep required tool-call/result and provider reasoning relationships intact.
- Determine what happens on cancellation, disconnect, reload and retries. Consuming a stream after disconnect still depends on the hosting lifetime; durable execution needs a supported durable runtime.
- Log redacted diagnostics with a correlation ID. Return a safe public error
for failed HTTP requests and in-stream failures; an error after headers have
been sent cannot change the HTTP status. The UI stream masks ordinary errors
by default; provider-executed tool errors can bypass
onError, so check the tool error renderer too. A customonErrorreturn value reaches the browser verbatim, and a non-2xx response reachesuseChatonErrorwith the raw response body as its message. - Verify actual proxy streaming and buffering configuration. SDK UI-message
responses already send
X-Accel-Buffering: no; streams you build yourself (NDJSON/SSE progress) need it andCache-Control: no-store, no-transform. The header helps supported nginx setups; it does not guarantee that every host streams without buffering.
Chat surface
Keep the answer, relevant tool results and useful sources readable. Default
layout: user messages in a right-aligned bg-muted bubble, assistant messages
full width without a background, and the brand carried through to the
scrollbar. Add feedback, regenerate, delete or suggestions when the product
needs them; avoid a repeated “Answer” heading or an action toolbar on every
message by default. Use the icons skill for icon choice and nextjs-shadcn
for the surrounding interface.
Follow streamed output while the reader is at the bottom; preserve their place
when they scroll away or load earlier history. Use an existing compatible
scroll primitive when it fits; shadcn's
Message Scroller is one option;
anchor on the user's message so the reply streams below it.
Render Markdown through the application's
renderer (Streamdown through the shadcn/ui Message pattern's Markdown
component in the default stack; MessageResponse in existing AI Elements
installs)
and style it with shadcn Typeset by default (CSS only, see nextjs-shadcn);
verify nested lists, long links and code blocks.
Derive turn completion from useChat status (submitted/streaming) rather
than a momentary gap between tools. Stop or isolate the generation before
switching conversations. Browser storage must not make the first client render disagree
with server-rendered consent or history.
Read for the feature
- Tool approval: policy, replay security and UI transitions.
- Persistence: IDs, history replay, feedback and resumption.
- Tool rendering: typed states and safe output.
- Popup/embedding: focus, scrolling and host boundaries.
- Retrieval: structured filters and evaluated search choices.
- Suggestions: optional, grounded next actions.
- Web search: source scope, freshness and provider capability.
- Verification: UI transitions and model/retrieval evals.
Exercise a second turn after restoring history, approval and denial, tool failure, cancellation, fast conversation switching and the deployed stream path. Report the behaviors actually checked.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

