js-nuxt in the deployment cookbook.
Deploy
- Vercel
- Netlify
- Node
Import the repository
Click Deploy with Vercel below, or import 
langchain-ai/deployment-cookbook manually.Required API endpoints
The app exposes the Agent Streaming Protocol under/api/threads/.... Nitro route handlers live in server/api/threads/.
Minimum (streaming chat)
These three endpoints are enough to run a single-threaded streaming chat with@langchain/vue’s HttpAgentServerAdapter:
| Method | Path | Purpose |
|---|---|---|
POST | /api/threads/:threadId/commands | Accept protocol commands (run.start, …) and start agent runs |
POST | /api/threads/:threadId/stream | SSE stream of protocol events for a run |
GET / POST | /api/threads/:threadId/state | Read and bootstrap checkpointed thread state |
GET /state (and POST /state on 404) so hydration does not 404 before the first message is sent.
Optional (thread sidebar)
This example also implements endpoints for the thread-history sidebar. Omit them if your UI does not need multi-thread management:| Method | Path | Purpose |
|---|---|---|
GET | /api/threads | List threads known to the checkpointer |
DELETE | /api/threads/:threadId | Delete a thread’s session and checkpoints |
POST | /api/threads/:threadId/history | Paginated checkpoint history (Agent Protocol) |
Request flow
- Bootstrap thread state (
GET/POST /state). - On submit, the SDK sends
run.startto/commandsand receives arun_id. - The SDK subscribes to
/stream(SSE) for replay + live protocol events. - Subagent (
task) runs emit namespaced events surfaced asstream.subagents.
Nitro backend design
| Concern | Implementation |
|---|---|
| Frontend | Vue components in app/ (wrapped in <ClientOnly> for SSE) |
| API layer | Nitro route handlers in server/api/threads/ |
| Runtime | Node.js (Nitro preset depends on deploy target) |
| SSE replay | Process-local LocalThreadSession (server/utils/session.ts) |
| Agent runs | Same Nitro process; events buffered in a LangGraph StreamChannel |
| Thread storage | In-memory MemorySaver checkpointer (server/agent/index.ts) |
| Secrets | .env locally; host environment variables in production |
Production persistence
Out of the box, the agent uses an in-memoryMemorySaver checkpointer (server/agent/index.ts) and a process-local session map (server/utils/runtime.ts). That works for local dev and single-instance servers, but on serverless or multi-instance hosts conversation state is not durable across cold starts or replicas.
For production, swap in a durable checkpointer:
| Package | Backend |
|---|---|
@langchain/langgraph-checkpoint-redis | Redis (RedisSaver) |
@langchain/langgraph-checkpoint-postgres | Postgres (PostgresSaver) |
@langchain/langgraph-checkpoint-sqlite | SQLite (SqliteSaver) |
MemorySaver in server/agent/index.ts and pass the new checkpointer to createDeepAgent. The Nitro route handlers and server/utils/threads.ts helpers stay the same.
You will also want a shared session/replay store in server/utils/runtime.ts so SSE reconnection works across serverless invocations.
For more information, see checkpointer libraries and add memory / persistence.
Local development
Project layout
Project structure
Project structure
server/agent/— deep agent (createDeepAgent) withresearcherandmath-whizsubagents, mock tools, andstripReasoningReplaymiddleware.server/utils/— protocol server logic:session.ts(SSE runs),threads.ts(checkpointer-backed state),serialize.ts,runtime.ts.server/api/threads/— Nitro route handlers for the protocol endpoints above.app/components/— Vue chat UI (ChatApp,Chat,ThreadHistory,SubagentList,MessageReasoning, …) using@langchain/vue.app/utils/threads.ts— server-driven thread helpers and LangGraph SDK bootstrap.
Backend details
Backend details
server/agent/index.ts— coordinator uses a reasoning model over the Responses API; tool-using subagents use chat-completions (to avoid reasoning item replay through the checkpointer).server/agent/middleware.ts— rebuilds prior assistant messages fromcontent+tool_callsso stale reasoning ids are never replayed to the Responses API.server/utils/session.ts—LocalThreadSessionbuffers protocol events and fans matching frames out over SSE viamatchesSubscription.server/api/threads/index.get.ts—GET /api/threads, the checkpointer-backed thread list.server/api/threads/[threadId]/…— handlers forcommands,stream,state(GET/POST),history, andDELETE.
Frontend details
Frontend details
app/components/ChatThread.vue— builds theHttpAgentServerAdapterand callsprovideStream({ transport, threadId }).app/components/Chat.vue— message view with composer and per-subagent detail view (with breadcrumb).app/components/SubagentList.vue/SubagentDetail.vue— inline subagent cards and scoped subagent chat (useMessagesbound to namespace).app/components/MessageReasoning.vue— collapsible “Thinking” block for reasoning summaries.
See also
- Frameworks and platforms overview
- Agent Streaming Protocol
react-custom-backend— original Vite + Hono reference for a custom protocol server@langchain/vue—useStream,provideStream, and selector composables- Frontend overview
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

