# Vite integrations and Provider Output

A Vite integration connects a package to Vite development and builds. Provider Output is what that integration generates for a host, such as routes, functions, bindings, workers, crons, or runtime files.

Configure the integration in Vite. Inspect Provider Output when you need to check host wiring. Application code uses the package's documented server API instead of generated internals.

## Configure the integration

```ts [vite.config.ts]
import { defineConfig } from 'vite'
import { vitehub } from 'vite-hub'

export default defineConfig({
  plugins: [
    vitehub({ preset: 'node', agent: true, kv: true }),
  ],
})
```

Put options in `vite.config.ts` when they affect discovery, generated files, provider bindings, or deployment. Put options in a Definition when they apply to that named item.

## Use Provider Output as build evidence

Inspect generated output to verify routes, bindings, or host wiring. Import it from application code only when the package documents a path such as `#vitehub/env/server`.

| Need | Surface |
| --- | --- |
| Development and build wiring | The package Vite Integration. |
| One named declaration | A Definition file. |
| Host deployment material | Provider Output generated by the integration. |
| Server code access | A documented package or generated import. |

Read [Definition discovery](https://vitehub.dev/docs/development/definition-discovery), [Runtime Helpers and stable imports](https://vitehub.dev/docs/reference/runtime-helpers), and [Provider Output](https://vitehub.dev/docs/reference/provider-output) for more detail.

## Persistent Node storage

Set `dataDir` in `vitehub()` to select a shared local storage directory on a Node host:

```ts
vitehub({
  preset: "node",
  dataDir: "/var/lib/app",
  agent: true,
  console: { exposure: "host-managed", authorize: "./server/console-authorize.ts" },
  kv: true,
  blob: true,
  workspace: true,
})
```

Enabled integrations use `agent-state.sqlite`, `console.sqlite`, `kv/`, `blob/`, and `workspaces/` under this directory. Inline Console Auth uses `console-auth.sqlite`. Named local KV and Blob stores get separate subdirectories. Explicit paths and remote providers take precedence; disabled services stay disabled. Relative paths resolve from the configuration process's working directory.

The host must provide a persistent, writable filesystem at this path. The option does not create a volume or make an ephemeral filesystem durable, and it is rejected for other presets. Keep the existing provider configuration for hosted storage.

## Public URL

Set `publicUrl` in `vitehub()` to the public origin of the deployed application. Console invocation links, GitHub activity links, Chat error links, trigger `failed` events, telemetry `session_url` values, and the default Auth `baseURL` use it:

```ts
vitehub({
  preset: "node",
  publicUrl: "https://agents.example.com",
})
```

Use a function when one build serves Agents from different origins. ViteHub calls it once per discovered Agent at build time, using its file-derived name. An explicit definition name resolves to that same origin at runtime. A shared definition discovered under several names has no implicit alias:

```ts
vitehub({
  preset: "node",
  publicUrl: agent => agent === "bot" ? "https://agent.example.com" : "https://agent-dev.example.com",
})
```

Standalone provider bundles receive the public origin and application base from their own resolved build configuration. Concurrent builds do not share URL constants.

The value must be an `http(s)` origin without a path. ViteHub adds the application base path. It applies to `vite build` only. During `vite dev`, request-bound Console links and Auth use the request origin. GitHub activity and evlog session links have no request-origin fallback. Set `activity.publicUrl` on the GitHub Channel or the evlog `sessionUrl` callback to supply links in development. Without `publicUrl`, request-bound links and Auth use the request origin, and links created outside a request are omitted. Auth uses the configured origin whose host matches the request host when the function form is set.

Use `agent.providers.state.url`, `console.databaseUrl`, `console.auth.databasePath`, or each store's path option to preserve an existing location. Existing runtime database URL overrides still take precedence. Changing the directory does not migrate stored data.
