# Frameworks and hosts

Pick one framework integration and one deployment host (a named host
target). At build time, ViteHub finds your Definitions and writes the files and
bindings the host needs. Your code keeps ViteHub imports, not generated paths
or provider SDKs.

## Choose a framework

| Framework | Register | Guide |
| --- | --- | --- |
| Vite | `vitehub()` from `vite-hub`. It includes Nitro's Vite plugin. | [Installation](https://vitehub.dev/docs/getting-started/installation) |
| Nuxt | The `vite-hub/nuxt` module | [Nuxt](https://vitehub.dev/docs/frameworks-hosts/nuxt) |

Both build the server output with Nitro.
[Nitro and UnJS](https://vitehub.dev/docs/frameworks-hosts/nitro-unjs) explains where ViteHub
packages register Nitro handlers. To move a Nuxt app off NuxtHub, read
[Migrate from NuxtHub](https://vitehub.dev/docs/getting-started/migrate-from-nuxthub).

## Choose a host

`host` selects the host, the Nitro preset, and each feature's default
provider. Without it, ViteHub detects the host in this order:

1. `VITEHUB_HOST`
2. `NITRO_PRESET`, then `SERVER_PRESET`
3. The build variables the host sets, the same ones Nitro reads:
   `WORKERS_CI` (Cloudflare Workers Builds), `NETLIFY`, `NOW_BUILDER`,
   `VERCEL` or `VERCEL_ENV`, then `DENO_DEPLOY` or `DENO_DEPLOYMENT_ID`
4. `node` when none of them is set

Cloudflare Pages is not detected, because the `cloudflare` host builds a
Worker. To set host-specific options, use `detectHost()` from
`vite-hub`:

### Nuxt

```ts [nuxt.config.ts]
import { detectHost } from "vite-hub";

const host = detectHost() ?? "node";

export default defineNuxtConfig({
  modules: ["vite-hub/nuxt"],
  // The deno host rejects Schedule.
  vitehub: { host, schedule: host !== "deno" },
});
```

### Nitro

```ts [vite.config.ts]
import { detectHost, vitehub } from "vite-hub";
import { defineConfig } from "vite";
import { nitro } from "nitro/vite";

const host = detectHost() ?? "node";

export default defineConfig({
  // The deno host rejects Schedule.
  plugins: [vitehub({ host, schedule: host !== "deno" }), nitro()],
});
```

### Vite

```ts [vite.config.ts]
import { detectHost, vitehub } from "vite-hub";
import { defineConfig } from "vite";

const host = detectHost() ?? "node";

export default defineConfig({
  // The deno host rejects Schedule.
  plugins: [vitehub({ host, schedule: host !== "deno" })],
});
```

`detectHost()` returns `undefined` when no variable names a host, so your
app picks the default.

| Host | Guide | Production output | Default providers | Rejected when enabled with `true` |
| --- | --- | --- | --- | --- |
| `node` | [Node and self-hosted](https://vitehub.dev/docs/frameworks-hosts/node-self-hosted) | `.output/server/index.mjs` | Blob `fs`, KV `database` with Postgres or `fs-lite`, Queue `local`, Rate Limit `memory` | Sandbox |
| `cloudflare` | [Cloudflare](https://vitehub.dev/docs/frameworks-hosts/cloudflare) | `.output/server/wrangler.json` | Blob R2, KV Workers KV, Queue, Rate Limit, and Sandbox on Cloudflare | None |
| `vercel` | [Vercel](https://vitehub.dev/docs/frameworks-hosts/vercel) | `.vercel/output/**` | Blob Vercel Blob, KV Upstash Redis, Vercel Queues, Vercel Sandbox | Rate Limit |
| `netlify` | [Netlify](https://vitehub.dev/docs/frameworks-hosts/netlify) | `.netlify/**` | Blob Netlify Blobs | Queue, Rate Limit, Sandbox |
| `deno` | [Deno](https://vitehub.dev/docs/frameworks-hosts/deno) | `.output/server/index.mjs` | KV Deno KV | Blob, Queue, Rate Limit, Sandbox, Schedule |

- A rejected feature fails the build. It does not fall back to another provider.
- Browser and `email: true` require the `cloudflare` host.
- Blob without an explicit store requires a host with a Blob provider.
- KV without an explicit driver uses Upstash Redis on every host except
  `deno` when `KV_REST_API_URL` and `KV_REST_API_TOKEN` are set at build time.
- ViteHub sets the Nitro preset. The build fails when `nitro.preset`,
  `NITRO_PRESET`, or `SERVER_PRESET` names a different one.

The [support matrix](https://vitehub.dev/docs/frameworks-hosts/support-matrix) lists every
primitive on every host, with explicit provider choices.

## Keep runtime imports stable

Import server APIs from documented ViteHub paths so the same code runs on
every host. Do not import framework virtual modules or generated files
unless a reference page marks the path public.

```ts [server/settings.ts]
import { kv } from 'vite-hub/kv'

export async function saveSettings(settings: Record<string, unknown>) {
  const [error] = await kv.set('settings', settings)
  if (error) throw error
}
```

Libraries can register one `hubX()` integration from its `@vite-hub/*/vite`
package instead of `vitehub()`.

## Inspect the output

Development proves discovery and local generation. A production build writes
the output for the host. List the generated host files with the CLI:

```bash [Terminal]
pnpm build
pnpm vitehub inspect output
```

## Next steps

- Read [Production deployment](https://vitehub.dev/docs/frameworks-hosts/production) before you serve traffic.
- Use [Provider output](https://vitehub.dev/docs/reference/provider-output) for generated host artifacts.
- Use [File conventions](https://vitehub.dev/docs/reference/file-conventions) for discovery paths.
- Use [Local development](https://vitehub.dev/docs/development) for local checks.

<!-- vitehub-docs:section-links -->
## In this section

- Choose a target
  - [Overview](https://vitehub.dev/raw/docs/frameworks-hosts.md) (this page)
  - [Support matrix](https://vitehub.dev/raw/docs/frameworks-hosts/support-matrix.md)
- [Frameworks](https://vitehub.dev/raw/docs/frameworks-hosts/nuxt.md)
- [Deployment hosts](https://vitehub.dev/raw/docs/frameworks-hosts/cloudflare.md)

Next: [Support matrix](https://vitehub.dev/raw/docs/frameworks-hosts/support-matrix.md)

All pages: [llms.txt](https://vitehub.dev/llms.txt)
