Skip to content

Search the guides, deployment pages, and API reference.

fetchServer

import { fetchServer } from "@pitlane/vite-plugin-fetch-server";
function fetchServer(options): Plugin;

Serves vite dev requests through the Fetch handler an application's server module exports. Every request Vite does not answer itself goes to the current default.fetch of entry, loaded through the environment's module runner on each request, so an edit applies to the next request. Errors go to Vite's development error page.

Development only: the plugin takes no part in vite build or vite preview. It sets appType: "custom" unless the config sets one.

Parameters

options

FetchServerOptions

The server module and the environment that loads it; see FetchServerOptions

Returns

Plugin

The plugin, passed to Vite as one entry of plugins

Throws

Error when entry is missing or empty

Throws

Error at dev server startup when environment does not exist or is not runnable

See

Fetch server guide

Example

vite.config.ts
import { fetchServer } from "@pitlane/vite-plugin-fetch-server";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [fetchServer({ entry: "src/http.ts" })],
});