{"id":22848,"library":"vite-plugin-srvx","title":"Vite Plugin for srvx","description":"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.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","vite","vite-plugin","srvx","server","ssr","typescript"],"install":[{"cmd":"npm install vite-plugin-srvx","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-srvx","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-srvx","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: peerDependencies specification requires srvx >=0.9.0","package":"srvx","optional":false},{"reason":"Peer dependency: requires Vite ^5.0.0 || ^6.0.0","package":"vite","optional":false}],"imports":[{"note":"Default import; CommonJS require may not work in ESM-only environments but plugin is primarily used in Vite config files which support both.","wrong":"const srvx = require('vite-plugin-srvx')","symbol":"default","correct":"import srvx from 'vite-plugin-srvx'"},{"note":"TypeScript type import for options object.","wrong":"","symbol":"SrvxOptions","correct":"import type { SrvxOptions } from 'vite-plugin-srvx'"},{"note":"Named export for custom loadModule option; not a default export.","wrong":"import loadModule from 'vite-plugin-srvx'","symbol":"loadModule","correct":"import { loadModule } from 'vite-plugin-srvx'"},{"note":"defineConfig is from Vite, not from this plugin.","wrong":"import { defineConfig } from 'vite-plugin-srvx'","symbol":"defineConfig","correct":"import { defineConfig } from 'vite'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite'\nimport srvx from 'vite-plugin-srvx'\n\nexport default defineConfig({\n  plugins: [\n    ...srvx({\n      entry: './src/server.ts',\n    }),\n  ],\n})\n\n// src/server.ts\nexport default {\n  async fetch(request: Request): Promise<Response> {\n    const url = new URL(request.url)\n    if (url.pathname === '/api/hello') {\n      return Response.json({ message: 'Hello from srvx!', timestamp: new Date().toISOString() })\n    }\n    return new Response('Not Found', { status: 404 })\n  },\n}\n\n// index.html\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>My srvx App</title>\n</head>\n<body>\n  <h1>Hello from srvx + Vite!</h1>\n  <script type=\"module\" src=\"/src/main.ts\"></script>\n</body>\n</html>","lang":"typescript","description":"Basic setup: Vite config, srvx server file, and index.html for dev with HMR."},"warnings":[{"fix":"Use ...srvx({...}) in the plugins array, not just srvx({...}).","message":"The plugin returns an array of Vite plugins (using spread), not a single plugin.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Add scripts: \"build\": \"vite build && vite build --mode server\"","message":"For production, you must run two separate Vite builds: one for client and one for server (with --mode server).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure export default { async fetch(request: Request): Promise<Response> { ... } }","message":"The plugin expects the entry file to export a default object with a 'fetch' method (Request => Response). Non-standard exports will break.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set framework option explicitly or unset VERCEL env var if not deploying to Vercel.","message":"When 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use ...srvx({...}) instead.","cause":"Using srvx({...}) without spread operator in plugins array.","error":"Error: The plugin returned an array, but Vite expects a single plugin."},{"fix":"Check entry option in srvx() and ensure server file exists.","cause":"Entry file path mismatch or missing entry file.","error":"Error: [vite] Internal server error: Failed to load module /src/server.ts"},{"fix":"Run npm install srvx","cause":"Missing srvx peer dependency.","error":"Error: Cannot find module 'srvx'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}