Registry / web-framework / vite-plugin-prerender-static

vite-plugin-prerender-static

JSON →
library0.1.3jsnpmunverified

A lightweight Vite plugin for static prerendering of SPAs to improve SEO. Version 0.1.3 supports Vite 4–7, Node 18+, and multiple routes with built-in SEO meta tag generation (Open Graph, Twitter, JSON-LD). It is framework-agnostic (React, Vue, Svelte, etc.) and requires zero runtime dependencies. Its key differentiator is simplicity: it avoids SSR complexity and provides a drop-in replacement for generating static HTML at build time. The plugin is actively maintained with recent updates and a roadmap for future features like CLI and automatic route discovery.

npm install vite-plugin-prerender-static
INSTALL
IMPORT
SIG · VITE-PLUGIN-PREREN
V
vite-plugin-prerender-static
web-frameworkjavascriptv0.1.3
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.

prerenderStatic
import prerenderStatic from 'vite-plugin-prerender-static';
import { prerenderStatic } from 'vite-plugin-prerender-static';
Default export. Named export will cause undefined error.
generateSEOTags
import { generateSEOTags } from 'prerender-core';
import { generateSEOTags } from 'vite-plugin-prerender-static';
generateSEOTags is from the separate 'prerender-core' package, not this plugin.
defineConfig
import { defineConfig } from 'vite';
Standard Vite export, not from the plugin.

Configures the plugin with two routes and a custom render function in a Vite config file.

import { defineConfig } from 'vite'; import prerenderStatic from 'vite-plugin-prerender-static'; export default defineConfig({ plugins: [ prerenderStatic({ routes: [ { path: '/', tags: { title: 'Home', description: 'Welcome to my site', }, }, { path: '/about', tags: { title: 'About', description: 'About us page', }, }, ], render: (route) => { return `<div id="root">Static content for ${route.path}</div>`; }, }), ], });
Debug
Known issues
breakingRequires Vite v4 or higher. Older versions are unsupported.
fix
Upgrade Vite to ^4 || ^5 || ^6 || ^7.
affects: <0.1.0
deprecatedThe 'tags' option can be a string or object. String format is deprecated in favor of object format.
fix
Use object format: tags: { title: '...' }
affects: >=0.1.0
gotchaIf no 'template.html' exists, the plugin auto-generates one. Ensure your project root does not have a conflicting file.
fix
Delete or rename any existing template.html if you want auto-generation.
affects: >=0.1.0
gotchaThe plugin only runs during build. It does not work in dev mode.
fix
Use Vite's build command, not dev server.
affects: >=0.1.0
deprecatedUsing 'render' function is optional; if omitted, a fallback is used. This fallback may not include your actual app content.
fix
Always provide a custom render function that generates the HTML for each route.
affects: >=0.1.0
Errors
Common errors & fixes
ERR_IMPORT_DEFAULT: Cannot import default export from non-module
Using named import '{ prerenderStatic }' instead of default import.
fix
Change to import prerenderStatic from 'vite-plugin-prerender-static';
[vite] Internal server error: Cannot find module 'template.html'
Missing template.html in project root when template option not set.
fix
Ensure template.html exists or set the template option to an existing file.
TypeError: route.path is undefined
Routes array has an entry without a 'path' property.
fix
Ensure each route object has a 'path' string.
Error: Route path must start with '/'
Path does not start with a forward slash.
fix
Add leading slash, e.g., 'about' -> '/about'.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
viterequiredPeer dependency for Vite plugin integration.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
vite-plugin-prerender-static — npm install vite-plugin-prerender-static · libregistry