next.js
94ffce78 - examples: add eve example (#100758)

Commit
11 days ago
examples: add eve example (#100758) ### What? This PR adds a new example, `examples/eve`. The example runs an [eve](https://eve.dev) agent and a Next.js App Router app as one project. It uses the `eve/next` integration. <img width="1300" height="747" alt="image" src="https://github.com/user-attachments/assets/18c99c82-53cc-42d6-ad44-9ef153516f56" /> ### Why? Next.js does not have an example that shows how to add an eve agent to an app. This example gives a minimal starting point. You can create the example with `create-next-app --example eve`. You can deploy it with the Deploy button. The agent and the app use the same origin. They deploy as one Vercel project. ### How? **`next.config.ts`** - The `withEve()` function wraps the Next.js config. - `withEve()` puts the agent from `agent/` at `/eve/v1/*`. This path is on the same origin as the app. - When you run `next dev`, the eve dev server starts with Next.js. Next.js sends the eve routes to the eve dev server. **`agent/`** - `agent.ts` sets the model. The agent connects to the model through Vercel AI Gateway. - `instructions.md` contains the system prompt. The agent is a weather assistant. - `tools/get_weather.ts` is a typed tool. It uses a `zod` schema for the input. It gives fake weather data. - `channels/eve.ts` sets the auth policy for browser requests. The policy uses `vercelOidc()`, `localDev()`, and `none()`. **`app/chat.tsx`** This file is a Client Component. It uses the `useEveAgent` hook from `eve/react`. The component does these tasks: - It shows the messages as they stream in. - It shows the tool calls. - It sends new messages into a turn that is still running ("steer"). - It stops a turn that is still running. - It starts a new session. - It prewarms the agent when the user types. **`README.md`** The README tells you how to: - Set the model key (`AI_GATEWAY_API_KEY` or Vercel OIDC). - Run the app in development. - Build the app for production. You must run `eve build` before `next build`. - Deploy the app with the Deploy button. You must use Node.js 24 or later. ### Security The channel uses `none()`. Because of this, a deployment from the Deploy button accepts anonymous requests. Any person who has the URL can use the agent. These requests use the AI Gateway credits of the person who deployed the app. The README gives this warning. It also gives a link to the eve auth guide. --------- Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
Author
Parents
Loading