# Self-hosting

Build Rebask with Vite and serve the production output from your own server. For Vercel, use the
[Vercel adapter](./vercel.md).

## Set up a server

Rebask doesn’t bundle an HTTP server by design. It focuses on routing and rendering and exposes a
fetch handler that can run on any server.

[Nitro](./nitro.md) is the recommended default: it runs the Rebask handler and provides presets for
Node, Bun, and other deployment targets. Install the Nitro adapter:

::package-manager

```bash [pnpm]
pnpm add @rebask/nitro
```

```bash [npm]
npm install @rebask/nitro
```

```bash [bun]
bun add @rebask/nitro
```

```bash [yarn]
yarn add @rebask/nitro
```

::

Add `rebaskNitro()` to your Vite plugins:

```ts
import { rebask } from "@rebask/core/vite"
import { rebaskNitro } from "@rebask/nitro"
import react from "@vitejs/plugin-react"
import rsc from "@vitejs/plugin-rsc"
import { defineConfig } from "vite"

export default defineConfig({
  plugins: [
    rsc(),
    react(),
    rebask(),
    rebaskNitro({
      preset: "node-server",
      serverDir: "./server",
    }),
  ],
})
```

Change `preset` to match your Nitro deployment target, then deploy with any Nitro target. See
[Nitro deployment](https://nitro.build/deploy).

> [PPR](../rendering/ppr.md) is available on the filesystem-based `node-server` and `bun` presets.
> Other Nitro targets run the app without PPR.

## Custom servers

For Elysia, Fastify, or another server, load Rebask's [proxy](../routing/proxy.md) and app handlers:

```ts
import { loadHandlers } from "@rebask/core/handlers"

const { handleProxy, handleApp } = await loadHandlers({
  root: new URL("./dist/", import.meta.url),
})
```

Call them in the order your server needs. `handleProxy` returns `null` when no proxy route answers,
so you can place your own routes or static files before or after either handler:

```ts
const proxied = await handleProxy(request)
if (proxied) return proxied

// your static files and routes

return handleApp(request)
```

[PPR](../rendering/ppr.md) works when the build cache and manifest are present. Servers that only
expose Node `req`/`res` need a small request adapter.
