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 eve package 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-vercel 6.3.5 or later, the first version that builds on Node.js 26.

Register the Vite plugin

Add eveSvelteKit() before sveltekit():

vite.config.ts
import { sveltekit } from "@sveltejs/kit/vite";
import { eveSvelteKit } from "eve/sveltekit";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [eveSvelteKit(), 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:

export default defineConfig({
  plugins: [
    eveSvelteKit({
      eveRoot: "../my-agent",
    }),
    sveltekit(),
  ],
});

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:

<script lang="ts">
  import { useEveAgent } from "eve/svelte";

  const agent = useEveAgent();
  let message = $state("");
  let isBusy = $derived(agent.status === "busy");
  let isInputDisabled = $derived(isBusy || agent.status === "resuming");

  async function handleSubmit() {
    const text = message.trim();
    if (!text || isInputDisabled) return;
    message = "";
    await agent.send(text);
  }
</script>

<form onsubmit={(event) => {
  event.preventDefault();
  void handleSubmit();
}}>
  <input bind:value={message} disabled={isInputDisabled} />
  <button type="submit" disabled={isInputDisabled}>Send</button>
</form>

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 dev starts 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 preview works the same way: the preview server proxies the eve routes. A server the plugin starts stops when the Vite server closes. Any tool that loads vite.config.ts in serve mode, such as Vitest, starts or reuses a server, so keep eveSvelteKit() 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.json is required. By default, each generated service runs the installed eve binary from its agent root, so agent directories don't need their own package.json. When the agents need their own build step, set eveBuildCommand:

    export default defineConfig({
      plugins: [
        eveSvelteKit({
          eveBuildCommand: "npm run build:eve",
        }),
        sveltekit(),
      ],
    });
  • Non-Vercel hosts. When the eve service runs on a separate origin, pass baseUrl directly to useEveAgent:

    const agent = useEveAgent({
      baseUrl: "https://agent.example.com",
    });

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/*:

vercel.json
{
  "services": {
    "web": { "root": ".", "framework": "sveltekit" },
    "eve": { "root": "agent", "framework": "eve", "buildCommand": "eve build" }
  },
  "rewrites": [{ "source": "/eve/v1/(.*)", "destination": { "service": "eve" } }]
}

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 its experimentalServices block) 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 experimentalServices with the services and rewrites shown above, and keep the Services Framework Preset.