- A route on your server passes the chat’s requests to the agent. It holds the service credential, since every request to the agent needs a Jaccard token, and that token must stay on your server.
- eve’s
useEveAgenthook runs in the page. It starts the session, sends messages, and streams the replies and approval requests into React state.
Before you start
- Your server has a service credential, listed in the agent’s
callers: see Access. - The steps use Next.js with the App Router. For other frameworks, see Other frameworks.
Try it on your machine
1
Set up the app
Create a Next.js app, then install eve at the version in the agent’s
package.json, for its React hook:2
Give your server the credential
Add the agent’s URL, from
jaccard agent get <agent>, and the credential to the app’s server environment:.env.local
3
Add the server helpers
lib/agent.ts
4
Add the route the browser calls
eve’s React hook calls
/eve/v1/* on your app’s own origin. This route passes on the requests a chat makes, and nothing else:app/eve/v1/[...path]/route.ts
5
Add the chat page
The page sends messages, streams the replies, and shows buttons when the agent asks the user to approve a tool, answer a question or sign in to a service:eve’s frontend documentation covers the hook. For a page with markdown, tool details and a saved session, see Use a styled chat page.
app/page.tsx
6
Chat with the agent
Start the app on this machine only, then open
http://127.0.0.1:3000 and send a message:Add your users
Before anyone else uses the chat, have your server name the signed-in user on each message, and let each user reach only their own sessions. Until then, the agent sees one caller, your service, so all your users share its memory, approvals and connections.1
Let your service speak for your users
Add the service to
forwarders and accept forwarded users in agent/channels/eve.ts, as in Access, then deploy.2
Add the user helpers
signedInUser returns the id of whoever is signed in to your app. Use your own sign-in. This version reads a cookie, so you can test with two users before wiring it up:lib/users.ts
3
Check the user on every request
Replace the route:If your page saves the session in the browser, as the shadcn/ui version does, remove it when a user signs out, so the next person on that browser starts their own chat.Each message costs model tokens, so limit how many a user can send, as you would any paid API.
app/eve/v1/[...path]/route.ts
Check it works
Use two users to check that the agent tells them apart and that each sees only their own conversation.-
Add a test sign-in route, and remove it before you ship:
app/login/route.ts
-
Give the agent a tool that reports who is calling, and deploy:
agent/tools/whoami.ts
-
Start the app on this machine only, since the test sign-in lets anyone who can reach it be any user:
npx next dev -H 127.0.0.1. Open/login?user=alicein one browser and/login?user=bobin a private window, and try: -
Copy alice’s session id from her browser’s network panel, where it appears in the
/eve/v1/session/<id>/streamrequest. In bob’s window, open/eve/v1/session/<id>/stream: your route should answer403“Not your session.”
Other frameworks
For Vue or Svelte, useuseEveAgent from eve/vue or eve/svelte, and port the route to your framework’s server routes with its three checks.
A server-rendered app, such as one in Python, can skip the route and the hook, and call the agent from your server as in Calls from your service.
Use a styled chat page
The shadcn/ui chat page
The shadcn/ui chat page
This version renders markdown in the replies, shows each tool call with its result, and keeps the session across reloads. It adds more packages: shadcn/ui’s chat components and Streamdown. It uses the same route, so the checks in Add your users still apply.Add shadcn/ui and its chat components, and Streamdown for markdown. In an app that already has shadcn/ui, start at Two small changes to the generated files:Each tool call shows as a line you can open. When the agent asks the user to approve a tool or answer a question, it sends the question and its buttons, and the page shows them until the user answers:
shadcn add.- In
app/layout.tsx, rename the font variable--font-geist-sansto--font-sans, the name shadcn/ui’s styles use. - In
app/globals.css, add@source "../node_modules/streamdown/dist/*.js";below the@importlines, so the replies’ markdown is styled.
app/page.tsx. This page keeps the session in the browser, so a reload brings the conversation back, and New chat starts a new one:app/page.tsx
components/tool-call.tsx