Vite.js plugin for pre-rendering HTML for SPAs. Current stable version is 0.2.0, with a low release cadence. It allows pre-rendering specified routes at build time, generating static HTML files to improve SEO and initial load performance. Differentiators include a simple configuration API, support for custom selectors to wait for content, and optional HTML minification via html-minifier. It is designed specifically for Vite and works with both JavaScript and TypeScript projects.
npm install vite-plugin-html-prerenderNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configures the plugin to pre-render '/' and '/about' routes, waiting for '#root' selector, with HTML minification enabled.
Set 'staticDir' to the same directory as your Vite's 'build.outDir' (default 'dist').
Set 'selector' to the correct query selector for your app's root element (e.g., 'main' or '#app').
Ensure your routes are fully rendered after the page loads. You can also increase the timeout or use a custom navigation behavior.
Use 'import' syntax in an ESM context. If your package.json doesn't have "type": "module", rename your vite config to .mjs or .mts.
Ensure the directory exists before running vite build, or adjust 'staticDir' to match your build output directory.
Wrap client-side code that uses 'window' in a check for 'typeof window !== "undefined"'.
No dependency data recorded yet.