Registry / web-framework / vite-plugin-srvx

vite-plugin-srvx

JSON →
library1.0.2jsnpmunverified

A Vite plugin (v1.0.2) that integrates srvx (Universal Server) with Vite's development server, enabling HMR and automatic index.html serving for srvx-based projects. It supports Node.js, Deno, Bun, and Vercel Edge Functions. Similar to @hono/vite-dev-server but for srvx. Monthly releases with TypeScript types. Key differentiator: srvx's universal runtime and built-in static file serving.

npm install vite-plugin-srvx
INSTALL
IMPORT
SIG · VITE-PLUGIN-SRVX
V
vite-plugin-srvx
web-frameworkjavascriptv1.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import srvx from 'vite-plugin-srvx'
const srvx = require('vite-plugin-srvx')
Default import; CommonJS require may not work in ESM-only environments but plugin is primarily used in Vite config files which support both.
SrvxOptions
import type { SrvxOptions } from 'vite-plugin-srvx'
TypeScript type import for options object.
loadModule
import { loadModule } from 'vite-plugin-srvx'
import loadModule from 'vite-plugin-srvx'
Named export for custom loadModule option; not a default export.
defineConfig
import { defineConfig } from 'vite'
import { defineConfig } from 'vite-plugin-srvx'
defineConfig is from Vite, not from this plugin.

Basic setup: Vite config, srvx server file, and index.html for dev with HMR.

// vite.config.ts import { defineConfig } from 'vite' import srvx from 'vite-plugin-srvx' export default defineConfig({ plugins: [ ...srvx({ entry: './src/server.ts', }), ], }) // src/server.ts export default { async fetch(request: Request): Promise<Response> { const url = new URL(request.url) if (url.pathname === '/api/hello') { return Response.json({ message: 'Hello from srvx!', timestamp: new Date().toISOString() }) } return new Response('Not Found', { status: 404 }) }, } // index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My srvx App</title> </head> <body> <h1>Hello from srvx + Vite!</h1> <script type="module" src="/src/main.ts"></script> </body> </html>
Debug
Known issues
breakingThe plugin returns an array of Vite plugins (using spread), not a single plugin.
fix
Use ...srvx({...}) in the plugins array, not just srvx({...}).
affects: >=1.0.0
gotchaFor production, you must run two separate Vite builds: one for client and one for server (with --mode server).
fix
Add scripts: "build": "vite build && vite build --mode server"
affects: >=1.0.0
gotchaThe plugin expects the entry file to export a default object with a 'fetch' method (Request => Response). Non-standard exports will break.
fix
Ensure export default { async fetch(request: Request): Promise<Response> { ... } }
affects: >=1.0.0
gotchaWhen using Vercel deployment, the plugin auto-detects VERCEL=1 env var and changes output path to dist/api/index.js. This may conflict with other configurations.
fix
Set framework option explicitly or unset VERCEL env var if not deploying to Vercel.
affects: >=1.0.0
Errors
Common errors & fixes
Error: The plugin returned an array, but Vite expects a single plugin.
Using srvx({...}) without spread operator in plugins array.
fix
Use ...srvx({...}) instead.
Error: [vite] Internal server error: Failed to load module /src/server.ts
Entry file path mismatch or missing entry file.
fix
Check entry option in srvx() and ensure server file exists.
Error: Cannot find module 'srvx'
Missing srvx peer dependency.
fix
Run npm install srvx
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
srvxrequiredPeer dependency: peerDependencies specification requires srvx >=0.9.0
viterequiredPeer dependency: requires Vite ^5.0.0 || ^6.0.0
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
vite-plugin-srvx — npm install vite-plugin-srvx · libregistry