Registry / web-framework / vite-react-ssg

vite-react-ssg

JSON →
library0.9.1-beta.1jsnpmunverified

Static-site generation for React on Vite, supporting React Router v6 with data routes, lazy loading, and dynamic routes via getStaticPaths. Current stable version is v0.9.0, with frequent beta releases, actively maintained. Provides SSR dev server, CSR fallback, ClientOnly component, CSS-in-JS support (styled-components), and critical CSS extraction via beasties/critters. Key differentiator: lightweight alternative to Next.js SSG/ISR for Vite + React projects, with ESM-only, TypeScript types included.

npm install vite-react-ssg
INSTALL
IMPORT
SIG · VITE-REACT-SSG
V
vite-react-ssg
web-frameworkjavascriptv0.9.1-beta.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.

ViteReactSSG
import { ViteReactSSG } from 'vite-react-ssg'
const ViteReactSSG = require('vite-react-ssg')
ESM-only; CommonJS require() will fail.
RouteRecord
import type { RouteRecord } from 'vite-react-ssg'
import { RouteRecord } from 'vite-react-ssg'
RouteRecord is a TypeScript type, import with `import type` to avoid runtime error.
ViteReactSSG (single-page)
import { ViteReactSSG } from 'vite-react-ssg/single-page'
import { ViteReactSSG } from 'vite-react-ssg/single-page' (same, but often confused with main import)
For single-page SSG without react-router-dom, import from 'vite-react-ssg/single-page'.

Minimal setup: define routes, export createRoot, run build. ViteReactSSG generates static HTML per route.

// vite.config.ts import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], }) // src/App.tsx import React from 'react' import type { RouteRecord } from 'vite-react-ssg' const routes: RouteRecord[] = [ { path: '/', element: <div>Hello SSG</div>, }, ] export default routes // src/main.tsx import { ViteReactSSG } from 'vite-react-ssg' import routes from './App' export const createRoot = ViteReactSSG({ routes }) // package.json scripts { "scripts": { "build": "vite-react-ssg build", "dev": "vite-react-ssg dev" } }
Debug
Known issues
breakingReact Router v7 now has built-in SSG support. vite-react-ssg is recommended only for v6 users.
fix
If using React Router v7, migrate to its official SSG. For v6, continue using vite-react-ssg.
affects: >=0.9.0
gotchahydrateRoot is not a function in React 19, fixed in v0.8.7.
fix
Upgrade to v0.8.7 or later to avoid hydration errors with React 19.
affects: >=0.8.5 <0.8.7
deprecatedcritters is deprecated in favor of beasties for critical CSS extraction.
fix
Install 'beasties' instead of 'critters' for better critical CSS support.
affects: >=0.9.0
gotchaUsing CommonJS require() to import vite-react-ssg will fail because it's ESM-only.
fix
Use ESM import syntax (import { ... } from 'vite-react-ssg').
affects: >=0.9.0
Errors
Common errors & fixes
Cannot find module 'vite-react-ssg' or its corresponding type declarations.
Missing type definitions because the package doesn't ship with types? Actually it does, but the import path may be wrong.
fix
Ensure you are using ESM import and that tsconfig.json includes 'moduleResolution': 'bundler' or 'node16'.
Error: ViteReactSSG is not a function
Trying to use require() on an ESM-only package.
fix
Change to ESM import: import { ViteReactSSG } from 'vite-react-ssg'
TypeError: (0 , vite_react_ssg__WEBPACK_IMPORTED_MODULE_0__.ViteReactSSG) is not a function
Webpack bundling issue; vite-react-ssg is designed for Vite only.
fix
Do not use vite-react-ssg with Webpack; it must be used with Vite.
Error: RouteRecord is not a constructor
Importing RouteRecord as a value instead of type.
fix
Use import type { RouteRecord } from 'vite-react-ssg' to avoid runtime inclusion.
Upgrade
Version history
0.9.1-beta.1latest on npm
Audit
Dependencies
react-router-domrequiredRequired for route definitions and client-side routing; peer dependency of version ^6.14.1.
beastiesoptionalOptional for critical CSS inlining (used over critters when available).
crittersoptionalOptional for critical CSS inlining, used as fallback if beasties not installed.
prettieroptionalOptional peer dependency for code formatting in generated files.
Agent activity
74 hits · last 30 days
node
64
OpenAI (training)
1
Resources
vite-react-ssg — npm install vite-react-ssg · libregistry