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
muslnode 18–223 runs
build_error
glibcnode 18–223 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"
}
}
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.
fixEnsure 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.
fixChange 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.
fixDo 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.
fixUse 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.