---
title: useEveAgent (Solid)
description: Use the eve Solid binding and its Solid-specific reactive interface.
url: "https://eve.dev/docs/guides/frontend/use-eve-agent-solid"
docs_index: /llms.txt
---

> For an index of all documentation, see [/llms.txt](/llms.txt).

`useEveAgent()` from `eve/solid` exposes the shared eve frontend client as Solid accessors and methods. It requires Solid 2 (`solid-js` 2); Solid 1 apps call the agent through the [Client SDK](/docs/guides/client). With npm, a Solid 1 project that installs eve needs `"overrides": { "eve": { "solid-js": "$solid-js" } }` in `package.json`, because npm otherwise rejects eve's optional `solid-js` 2 peer. See the [frontend overview](/docs/guides/frontend) for session behavior, messages, human input, authorization, callbacks, and persistence.

## Set up a Solid app

Your project needs an eve agent directory next to the app. If you don't have one, start from [Getting started](../../getting-started). Install eve, Solid, and Vite:

```bash
npm install eve ai solid-js @solidjs/web
npm install -D vite @solidjs/vite-plugin
```

Register the [`eveVite()` plugin](./vite) beside Solid's start mode. It mounts the agent routes on the application origin in development and deploys them with the app on Vercel:

```ts title="vite.config.ts"
import solid from "@solidjs/vite-plugin";
import { eveVite } from "eve/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [solid({ start: true }), eveVite()],
});
```

For server rendering, set `ssr: true` and add `nitro()` from `nitro/vite` (`npm install nitro`). On Vercel, Nitro writes the app's Build Output, and `eveVite()` adds the agent routes to it:

```ts title="vite.config.ts"
import solid from "@solidjs/vite-plugin";
import { eveVite } from "eve/vite";
import { nitro } from "nitro/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [solid({ start: true, ssr: true }), nitro(), eveVite()],
});
```

Before you deploy, configure auth in `agent/channels/eve.ts`. Until then, production browser requests get `401`. See [Authenticate browser requests](/docs/guides/frontend#authenticate-browser-requests).

## Basic usage

Call the binding once for a conversation and call its accessors to read state:

```tsx title="src/App.tsx"
import { useEveAgent } from "eve/solid";
import { createSignal, For, Show } from "solid-js";

export default function App() {
  const agent = useEveAgent();
  const [message, setMessage] = createSignal("");
  const isInputDisabled = () => agent.status() !== "idle";

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

  return (
    <>
      <For each={agent.messages()} keyed={(item) => item.id}>
        {(item) => (
          <p>
            {item().role}: {JSON.stringify(item().parts)}
          </p>
        )}
      </For>
      <Show when={agent.error()}>{(error) => <p role="alert">{error().message}</p>}</Show>
      <form
        onSubmit={(event) => {
          event.preventDefault();
          void handleSubmit();
        }}
      >
        <input
          value={message()}
          onInput={(event) => setMessage(event.currentTarget.value)}
          disabled={isInputDisabled()}
        />
        <button type="submit" disabled={isInputDisabled()}>
          Send
        </button>
      </form>
    </>
  );
}
```

Key the `<For>` on `item.id` so a streaming message updates its row in place; with a `keyed` function, each row receives the message as an accessor.

## Share or switch a conversation

Call `useEveAgent()` inside a component or `createRoot()`. Without a reactive owner, such as at module level, it throws.

To share one conversation across components, create it in a context provider. In a server-rendered app, prefer the provider over a module-level `createRoot()`, because the server would share that root's conversation across requests:

```tsx title="src/agent-context.tsx"
import type { JSX } from "@solidjs/web";
import { useEveAgent, type UseEveAgentReturn } from "eve/solid";
import { createContext, useContext } from "solid-js";

const AgentContext = createContext<UseEveAgentReturn>();

export function AgentProvider(props: { readonly children: JSX.Element }) {
  return <AgentContext value={useEveAgent()}>{props.children}</AgentContext>;
}

export const useAgent = () => useContext(AgentContext);
```

The binding reads its options once. To switch conversations, remount the component that calls it: wrap that component in `<Show when={chatId()} keyed>` so a new id renders a fresh instance. This takes the place of React's `key` prop:

```tsx
<Show when={chatId()} keyed>
  {(id) => <Chat chatId={id} />}
</Show>
```

## What it returns

The state fields are Solid accessors; the commands are ordinary methods:

| Property                                                                                            | Solid shape                                 |
| --------------------------------------------------------------------------------------------------- | ------------------------------------------- |
| `messages`, `agents`                                                                                | Accessors for the snapshot fields           |
| `view`                                                                                              | `Accessor<SessionView>`                     |
| `status`                                                                                            | `Accessor<UseEveAgentStatus>`               |
| `error`                                                                                             | `Accessor<Error \| undefined>`              |
| `events`                                                                                            | `Accessor<readonly SessionStreamEvent[]>`   |
| `session`                                                                                           | `Accessor<ClientSessionState \| undefined>` |
| `send`, `respond`, `prewarm`, `resume`, `follow`, `cancel`, `clear`, `compact`, `end`, `newSession` | Methods                                     |

Call the accessors in JSX, `createMemo`, or `createEffect` to track them. Destructuring keeps reactivity because each state value is an accessor. The [`useEveAgent` reference](./use-eve-agent#returned-state) describes what each value and command does.

## Server rendering

During server rendering, the accessors return the initial state, built from `initialEvents` and `initialSession` when you pass them. The binding sends no requests on the server. In the browser, it connects once the component settles, after pending async reads finish, and disconnects when its owner is disposed.

## Send a message

Call `agent.send(text)` for text or pass content parts for attachments. The API and streaming behavior match the [sending reference](./use-eve-agent#sending). `send()` and `respond()` resolve with a `Delivery` receipt when the server accepts the request, before the agent finishes. Read the receipt's `sessionId` and `deliveryId`, or use its [`stream()` and `result()` reads](../client/messages#reusable-delivery-reads).

## Human-in-the-loop prompts

Read requests from the shared `view` and answer them with `respond()`. A request stays open until `interaction.settled`, even after you submit an answer.

```tsx
import { openInteractions } from "eve/events";
import { useEveAgent } from "eve/solid";
import { createMemo, For } from "solid-js";

export function PendingRequests() {
  const agent = useEveAgent();
  const pendingRequests = createMemo(() =>
    openInteractions(agent.view()).filter(
      (item) => item.request.kind !== "sign-in" && item.answer === undefined,
    ),
  );

  return (
    <For each={pendingRequests()} keyed={(item) => item.interactionId}>
      {(item) => (
        <fieldset disabled={agent.status() === "resuming"}>
          <legend>{item().request.prompt}</legend>
          <For each={item().request.options ?? []} keyed={(option) => option.id}>
            {(option) => (
              <button
                type="button"
                onClick={() =>
                  void agent.respond([
                    { interactionId: item().interactionId, optionId: option().id },
                  ])
                }
              >
                {option().label}
              </button>
            )}
          </For>
        </fieldset>
      )}
    </For>
  );
}
```

See [Human-in-the-loop prompts](/docs/guides/frontend#human-in-the-loop-prompts) for request semantics and rendering guidance.

<a id="cancel-reset-and-resume" />

## Cancel, end, and resume

Pass `prewarm: true` to create the session on mount and after `newSession()`. Omit it to create the session on the first send. The binding keeps the session stream open across turns. See [Prewarming](./use-eve-agent#prewarming) for creation and failure behavior, and [Stream lifetime](./use-eve-agent#stream-lifetime) for connection behavior.

Call `agent.cancel()` to stop the turn on the server; the binding stays attached until the turn ends. Offer it while `activeTurn(agent.view())` from `eve/events` returns a turn, because `agent.status()` reports outstanding work and is `"idle"` while a turn waits only on a person. Unmounting the component only disconnects its local stream, and the turn keeps running on the server.

Call `agent.newSession()` to clear local state and start a new session; `agent.end()` instead ends the session on the server.

Pass `initialSession`, `initialEvents`, and `resume: true` to restore a saved conversation and follow a turn that is still running. During catch-up, `agent.status()` is `"resuming"`. Keep the restored conversation visible, and disable submission until it changes to `"idle"` or `"busy"`. Failures appear in the separate `error` accessor. Call `agent.resume()` directly to control restoration imperatively. See [Resume a saved session](./use-eve-agent#resume-a-saved-session) for the persistence contract and [Cancelling](./use-eve-agent#cancelling) for cancellation behavior.

## Custom host and credentials

Pass `baseUrl`, `auth`, or `headers` to the binding, as with the other frontend bindings. See [Custom hosts and headers](/docs/guides/frontend#custom-hosts-and-headers).

## Attach page context per turn

Pass `clientContext` to `send()` or `respond()`, or use `prepareSend` to add context before every turn. See [Attach page context per turn](/docs/guides/frontend#attach-page-context-per-turn).

## Lifecycle callbacks

Pass `onEvent`, `onError`, `onFinish`, or `onSessionChange` to react to events, errors, finished turns, and session changes. See [Lifecycle callbacks](./use-eve-agent#lifecycle-callbacks) for when each one fires and how optimistic messages behave.

## Derive your own state

Use `agent.view()` and selectors from `eve/events` for session state, and `agent.messages()` for rendering. See [Session views & selectors](/docs/concepts/session-views-and-selectors) for the shared queries. In Solid, call `agent.view()` inside `createMemo` to keep selector results reactive.

## What to read next

- [Vite](./vite): register the `eveVite()` plugin and mount the eve runtime.
- [Frontend overview](/docs/guides/frontend): use the shared frontend API.
- [Sessions, runs, and streaming](../../concepts/sessions-runs-and-streaming): understand the underlying session protocol.

---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/llms.txt](/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/agents.md](/agents.md)