Registry / web-framework / vite-plugin-ssg

vite-plugin-ssg

JSON →
library0.1.0jsnpmunverified

A Vite plugin for static site generation with React and island architecture (partial hydration). Version 0.1.0. Currently in early development with frequent breaking changes. Key differentiators: island-based partial hydration, built-in image optimization (WebP/AVIF), per-page CSS extraction with Tailwind support, and Firebase hosting configuration automation. Ships TypeScript types.

npm install vite-plugin-ssg
INSTALL
IMPORT
SIG · VITE-PLUGIN-SSG
V
vite-plugin-ssg
web-frameworkjavascriptv0.1.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

ssgPlugin
✓ import { ssgPlugin } from 'vite-plugin-ssg'
✗ import ssgPlugin from 'vite-plugin-ssg'
The plugin is exported as a named export, not default. Use destructured import.
Island
✓ import { Island } from 'vite-plugin-ssg'
✗ import { IslandComponent } from 'vite-plugin-ssg'
The interactive island component is exported as `Island`.
SsgOptions
✓ import type { SsgOptions } from 'vite-plugin-ssg'
✗ import { SsgOptions } from 'vite-plugin-ssg'
SsgOptions is a TypeScript type, not a runtime value. Import it using `import type` to avoid runtime inclusion.

Minimal setup for Vite SSG with React: configure plugin, create a page with SSR options, and define an island component for partial hydration.

// vite.config.ts import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { ssgPlugin } from 'vite-plugin-ssg'; export default defineConfig({ plugins: [ react(), ssgPlugin({ pages: ['src/pages/HomePage.tsx'], config: { outDir: 'dist/static', baseUrl: '/static', images: { enabled: true, formats: ['webp'], quality: 80 }, css: { minify: 'lightningcss' }, js: { minify: 'terser' }, }, verbose: false, }), ], }); // src/pages/HomePage.tsx import type { SsgOptions } from 'vite-plugin-ssg'; import { Island } from 'vite-plugin-ssg'; export const ssgOptions: SsgOptions = { slug: 'home', routeUrl: '/', Head: () => ( <> <title>My Home Page</title> <meta name="description" content="Welcome" /> </> ), }; export default function HomePage() { return ( <div> <h1>Welcome</h1> <Island component="components/Counter" props={{ count: 0 }} /> </div> ); } // src/components/Counter.tsx 'use island'; import { useState } from 'react'; export default function Counter({ count }: { count: number }) { const [value, setValue] = useState(count); return <button onClick={() => setValue(v => v + 1)}>{value}</button>; } // Build command // npm run build
Debug
Known issues
breakingVersion 0.1.0 is an initial release; API may change without notice. Do not use in production without pinning exact version.
fix
Add `"vite-plugin-ssg": "0.1.0"` to dependencies with exact version pinning.
affects: 0.1.0
gotchaIsland components must have `'use island'` directive at the top of the file. Missing this directive will cause hydration errors.
fix
Add `'use island';` as the first line in island component files.
affects: >=0.1.0
gotchaIsland props must be JSON-serializable. Passing functions, Date objects, or React elements will cause runtime errors.
fix
Ensure props are plain objects, strings, numbers, booleans, or arrays thereof.
affects: >=0.1.0
deprecatedThe `slug` option in SsgOptions is currently required but may become optional in future versions. For now, always provide a slug.
fix
Set `slug` to a unique string for each page.
affects: 0.1.0
gotchaThe `component` prop in Island must be a path relative to the srcDir (default: 'src'). Do not include leading './' or '../'.
fix
Use `component='components/Widget'` instead of `component='./src/components/Widget'`.
affects: >=0.1.0
breakingThe plugin requires Vite 5+ and React 18+. Older versions are not supported.
fix
Ensure your project uses Vite 5.x and React 18+.
affects: >=0.1.0
Errors
Common errors & fixes
Error: 'use island' directive must be at the top of the file
Island component file missing the `'use island'` directive or it is not the first line.
fix
Add `'use island';` as the very first line of the island component file.
TypeError: ssgPlugin is not a function
Importing the plugin incorrectly (e.g., default import instead of named import).
fix
Use `import { ssgPlugin } from 'vite-plugin-ssg';` (named import).
Error: Missing required option 'pages'
The `ssgPlugin` was called without the `pages` option.
fix
Provide `pages` array with paths to page files or folders.
Error: Component '...' not found in src directory
The `component` prop in Island points to a non-existent file or incorrect path.
fix
Ensure the path is relative to the configured `srcDir` (default 'src').
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
@tailwindcss/viteoptionalRequired for Tailwind CSS support in version 4
@vitejs/plugin-reactrequiredRequired for React Fast Refresh and JSX transform
reactrequiredPeer dependency for React versions 18 or 19
react-domrequiredPeer dependency for React DOM
viterequiredPeer dependency for Vite version 5 or higher
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources