SvelteKit
eve/sveltekit runs a SvelteKit frontend and an eve agent as one project. The eveSvelteKit() Vite plugin puts both on one dev server and one Vercel deploy. useEveAgent finds the mounted routes on its own, so you configure no CORS or URL env vars.
Prerequisites
- The
evepackage installed in your project (npm install eve@latest). - An existing eve agent directory. If you don't have one, start from Getting started.
- A SvelteKit app to mount the agent in. To deploy on Vercel, use
@sveltejs/adapter-vercel6.3.5 or later, the first version that builds on Node.js 26.
Register the Vite plugin
Add eveSvelteKit() before sveltekit():
The plugin looks for an agent/ folder in the SvelteKit project root, mounted at /eve/v1/*. An agents/ workspace mounts each member at /eve/<name>/v1/* instead. Pass eveRoot when the agent lives elsewhere:
The plugin accepts three options: eveRoot, eveBuildCommand, and devServerTimeoutMs, the maximum time to wait for the eve development server to start (default 180000).
Call the binding
With the plugin registered, components call useEveAgent from eve/svelte and don't pass baseUrl:
The browser still needs a production authentication policy. See Authenticate browser requests for the default policy, which rejects unverified requests, and for channel configuration.
Dev vs deploy topology
-
Local dev.
npm run devstarts an eve dev server for each agent and proxies its routes to it. The browser talks only to the SvelteKit origin.npm run build && npm run previewworks the same way: the preview server proxies the eve routes. A server the plugin starts stops when the Vite server closes. Any tool that loadsvite.config.tsin serve mode, such as Vitest, starts or reuses a server, so keepeveSvelteKit()out of a separate test config. -
Vercel. The SvelteKit app and the eve runtime deploy as a single project. On Vercel builds, the plugin adds an eve service per agent and routes its transport requests to it before filesystem routing. The SvelteKit app serves everything else, and no
vercel.jsonis required. By default, each generated service runs the installed eve binary from its agent root, so agent directories don't need their ownpackage.json. When the agents need their own build step, seteveBuildCommand: -
Non-Vercel hosts. When the eve service runs on a separate origin, pass
baseUrldirectly touseEveAgent:
Managing vercel.json yourself
When vercel.json declares services, the plugin generates nothing, and your configuration controls routing. It must include an eve service (framework: "eve") per agent and a rewrite that sends its requests to it, or the build fails. An agents/ workspace needs one service per member, and a rewrite for /eve/<name>/v1/*:
Remove experimentalServices
Vercel doesn't route the experimentalServices field in vercel.json: both services build, but every /eve/v1/* request returns NOT_FOUND. The plugin ignores the field and warns that vercel.json defines experimentalServices. Remove it in one of two ways:
- Generated (default). Delete
vercel.json(or itsexperimentalServicesblock) and set the project's Framework Preset to SvelteKit. The plugin generates the eve service and its routing on every Vercel build. - Hand-maintained. Replace
experimentalServiceswith theservicesandrewritesshown above, and keep the Services Framework Preset.
What to read next
useEveAgent(Svelte): the binding API- Auth & route protection
- Deployment