The frontend helpers put a browser chat or agent UI on top of an eve agent without CORS configuration or URL environment variables.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/vercel/eve/llms.txt
Use this file to discover all available pages before exploring further.
useEveAgent() opens a durable session, sends turns, streams the reply back, and turns the raw event stream into render-ready state. React is the reference implementation; Vue and Svelte ship the same surface.
The integration model
A browser UI is a client of the agent’s HTTP routes. Two layers wire it up:- The framework plugin mounts the eve routes on your app’s origin, so the browser never crosses a CORS boundary or reads an env var to find the agent. Pick yours:
withEvefor Next.js, theeve/nuxtmodule for Nuxt, or theeveSvelteKitVite plugin for SvelteKit. - The hook (
useEveAgent) holds the session state, streaming, errors, and composer status. It defaults to same-origin routes such as/eve/v1/session.
Next.js setup
eve/next ships a Next.js frontend and an eve agent as a single project. Wrap your config with withEve() to run both from one dev server and one Vercel deploy.
Wrap the Next.js config
next.config.ts
withEve() looks for an agent/ folder inside your Next.js project root. If the agent lives somewhere else, point at it with eveRoot:
next.config.ts
withEve options
| Option | Type | Default | Purpose |
|---|---|---|---|
eveRoot | string | Next.js app root | Path to the eve app root, relative to process.cwd() unless absolute |
eveBuildCommand | string | "eve build" | Build command for the generated eve Vercel service |
servicePrefix | string | "/_eve_internal/eve" | Private Vercel route namespace for the eve service |
devServerTimeoutMs | number | 180000 | Maximum wait for the eve dev server to become available |
Dev vs deploy topology (Next.js)
- Local dev.
npm run devboots the eve dev server next tonext devand rewrites the eve routes to it. The browser only ever talks to the Next.js origin. - Vercel. The web app and the eve runtime deploy as a single project on the same site origin.
- Local production build. Run
eve buildfirst, thennext build && next start. The preview server proxies eve routes to the built output on a stable local port (4274). Override withEVE_NEXT_PRODUCTION_PORT. - Non-Vercel hosts. When the eve service lives on a separate origin, set
EVE_NEXT_PRODUCTION_ORIGINat build time.
SvelteKit setup
eve/sveltekit runs a SvelteKit frontend and an eve agent as one project. The eveSvelteKit() Vite plugin handles dev and deploy wiring automatically.
Register the Vite plugin
AddeveSvelteKit() before sveltekit():
vite.config.ts
eveRoot when the agent lives outside the SvelteKit project root, or eveBuildCommand when the agent needs a project-specific build step:
vite.config.ts
Basic chat: useEveAgent
The hook lives in eve/react, eve/vue, or eve/svelte depending on your framework. Render data.messages, gate the composer on status, and send text with send:
- React
- Svelte
components/Chat.tsx
Returned state
useEveAgent() returns the current UI state plus commands:
| Field | What it is |
|---|---|
data | Projected UI state from the reducer. Defaults to { messages }. |
status | "ready", "submitted", "streaming", or "error". Drives the composer. |
error | The last Error thrown, if any. |
events | Raw eve stream events for this session. |
session | Serializable session cursor (sessionId, continuationToken, streamIndex). |
send | Send text or the full turn payload (multi-part messages, HITL responses). |
stop | Abort the active request. |
reset | Clear local events, data, errors, and the local session cursor. |
data.messages follows the AI SDK UIMessage convention and drops straight into any AI SDK UI primitive that accepts UIMessage[]. Parts include user text, assistant text, reasoning, tool calls, tool results, and input requests.
Sending attachments and multi-part messages
Pass an object tosend() for text, multi-part messages, attachments, HITL responses, and per-turn context:
status moves from ready → submitted → streaming → ready as the turn progresses. Call stop() to abort, and reset() to clear local state so the next send starts a fresh durable session.
Human-in-the-loop prompts
When a tool requests approval or the model asks a question, the stream emitsinput.requested. The pending request rides on a dynamic-tool part of the latest message. Read it, then answer through the same session:
request.prompt and request.options give you what you need to render the approve and deny UI.
Attaching page context per turn
clientContext adds ephemeral context for the next model call only. It never lands in durable session history and doesn’t dispatch a turn by itself:
prepareSend. It runs right before each send and returns the (possibly augmented) turn:
Lifecycle callbacks
optimistic(defaulttrue): projects submitted user messages intodatabefore eve confirms them.maxReconnectAttempts(default3): stream reconnection budget per turn.
Custom reducer
The default reducer projects events into{ messages }. Pass a reducer implementing EveAgentReducer<TData> when you want data shaped differently:
Resumable sessions
Persist both the rendered event log and thesession cursor to pick the conversation back up after a reload:
session object (sessionId, continuationToken, streamIndex), not a single field. For multiple chat threads, keep one saved event log and session cursor per thread, and remount the chat component when switching — for example with key={chat.id}.
Custom hosts and auth headers
Passhost when the eve server isn’t same-origin, and auth or headers when the channel requires credentials. Function values are re-resolved before every request, reconnects included:
headers:
Channel auth
The default eve channel is fail-closed. Without an authoredagent/channels/eve.ts, eve registers eveChannel({ auth: [localDev(), vercelOidc()] }): localDev() opens routes on localhost, vercelOidc() admits Vercel OIDC callers in production, and everything else gets a 401.
To set your own auth policy, add agent/channels/eve.ts:
agent/channels/eve.ts
Per-framework integration summary
| Framework | Plugin | Hook |
|---|---|---|
| Next.js | withEve (eve/next) | useEveAgent (eve/react) |
| Nuxt | eve/nuxt module | useEveAgent (eve/vue) |
| SvelteKit | eveSvelteKit (eve/sveltekit) | useEveAgent (eve/svelte) |
| Any React | same-origin or host | useEveAgent (eve/react) |
What to read next
Client SDK
Lower-level TypeScript SDK for scripts, server code, and evals
Deployment
Ship your eve agent and frontend to Vercel or your own host
Channels
The HTTP routes the hook talks to
Custom Channels
Build custom channel adapters for your own platform