vite-plugin-html-pages (v1.6.8) is a minimal static site generation plugin for Vite that uses JavaScript functions returning HTML strings, built on the javascript-to-html library. It employs file-based routing akin to Next.js's pages router—supporting static, dynamic ([slug]), multiple parameters, catch-all, optional catch-all, index routes, and route groups. Unlike full-featured SSGs like Astro or Nuxt, this plugin provides a lightweight, framework-agnostic approach to generating static HTML without a component system or complex build pipeline. It automatically generates sitemap.xml, 404.html, RSS feeds, and includes dev server SSR rendering with fetch caching. Ships TypeScript types. Requires Vite >=5 and Node >=18. Release cadence: active maintenance with frequent updates.
npm install vite-plugin-html-pagesVerified import paths — ran on the pinned version, not inferred.
Creates a Vite project that generates a static index.html from a JavaScript function using vite-plugin-html-pages and javascript-to-html.
Rename all .page.js files to .ht.js and update imports/configuration accordingly.
Remove async keyword from generateStaticParams. Use synchronous pattern; if async data loading is needed, pre-fetch outside the function.
Use alternative route grouping methods if available, or prepare for removal by restructuring routes.
Install the peer dependency: npm install javascript-to-html
Install React and ReactDOM: npm install react react-dom
Review route tree to avoid conflicts; static routes take precedence over catch-all.
Add and export a generateStaticParams function in the file: export function generateStaticParams() { return [...] }Change import: import htmlPages from 'vite-plugin-html-pages' (remove curly braces).
Run: npm install javascript-to-html
Remove the async keyword: export function generateStaticParams() { ... } (synchronous).