Registry / web-framework / vite-plugin-ssr-ssg

vite-plugin-ssr-ssg

JSON →
library1.4.1jsnpmunverified

Vite plugin for SSR and SSG across multiple frameworks (React, Preact, Vue). Current stable version is 1.4.1 (March 2021). Release cadence is irregular with minor feature releases and bug fixes. Key differentiators: declarative entry point, automatic page generation, preview in both SSR and CSR, convenient init script. Compared to vite-ssr and vite-ssg, it aims for cross-framework support and simpler CLI commands. Last release was over a year ago, so it's in maintenance mode.

npm install vite-plugin-ssr-ssg
INSTALL
IMPORT
SIG · VITE-PLUGIN-SSR-SS
V
vite-plugin-ssr-ssg
web-frameworkjavascriptv1.4.1
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 vitePluginSsrSsg from 'vite-plugin-ssr-ssg'
const vitePluginSsrSsg = require('vite-plugin-ssr-ssg')
ESM-only package; require() will fail. Use TypeScript with ESM.
defineConfig
import { defineConfig } from 'vite-plugin-ssr-ssg'
import { defineConfig } from 'vite'
defineConfig is a re-exported helper from vite; using vite's directly works but plugin's version provides SSG defaults in v1.2+
VitePluginSsrSsgOptions
import type { VitePluginSsrSsgOptions } from 'vite-plugin-ssr-ssg'
import { VitePluginSsrSsgOptions } from 'vite-plugin-ssr-ssg'
Options interface is a type-only import in v1.4+. Use `import type` for TS

Configuration example with React: sets up Vite with the plugin and defines static routes for SSG.

// vite.config.ts import { defineConfig, VitePluginSsrSsgOptions } from 'vite-plugin-ssr-ssg'; import react from '@vitejs/plugin-react'; const ssgOptions: VitePluginSsrSsgOptions = { // optional: custom routes for SSG routes: ['/', '/about'], }; export default defineConfig({ plugins: [ react(), vitePluginSsrSsg(ssgOptions), ], });
Debug
Known issues
gotchaPlugin uses ESM-only distribution; requires Vite with ESM and Node >=12. CJS imports break.
fix
Use `import` syntax in all files. Set `"type": "module"` in package.json or use `.mjs` extension.
affects: >=1.4.0
deprecatedIn v1.3.0, the `init` script changed to use `vite-ssrg init` but older versions used `vite-ssrg-init`.
fix
Run `yarn vite-ssrg init` or `npx vite-ssrg init`.
affects: >=1.3.0 <1.3.0
breakingv1.4.0 changed rollup config output format; plugins expecting CJS may fail.
fix
Update any custom rollup configuration in vite.config.ts to use ESM format.
affects: >=1.4.0
gotchaPreact import path changed in v1.4.0 from 'preact' to 'preact/compat' to match SSR expectations.
fix
If using Preact, update imports to `import { h } from 'preact/compat'` or configure plugin with preactCompat option.
affects: >=1.4.0
deprecatedThe `routes` option in plugin config was deprecated in v1.3.0 in favor of automatic route detection. Manual routes still work but will be removed in v2.
fix
Remove `routes` from plugin options and rely on automatic detection.
affects: >=1.3.0
Errors
Common errors & fixes
Cannot find module 'vite-plugin-ssr-ssg' or its corresponding type declarations.
Package is not installed or Node cannot resolve ESM package.
fix
Install the package: `npm install vite-plugin-ssr-ssg`. Ensure Node >=12 and your project uses ESM (`"type": "module"` in package.json).
TypeError: vitePluginSsrSsg is not a function
Incorrect import (default vs named) or CJS require used instead of ESM import.
fix
Use `import vitePluginSsrSsg from 'vite-plugin-ssr-ssg'` (default import).
Error: The plugin 'vite-plugin-ssr-ssg' doesn't support the current Vite version
Vite version is incompatible (<2.0).
fix
Upgrade Vite to >=2.0.0.
Upgrade
Version history
1.4.1latest on npm
Audit
Dependencies
viterequiredCore peer dependency; plugin requires Vite >=2.0
Agent activity
7 hits · last 30 days
node
4
OpenAI (training)
1
Resources
vite-plugin-ssr-ssg — npm install vite-plugin-ssr-ssg · libregistry