HT.JS has its very own fully-featured Vite plugin
vite-plugin-html-pages Generate static HTML pages from JavaScript using Vite.
Write pages as `.ht.js` or `.ht.ts` files and build fast, predictable websites with zero runtime and no framework.
> All the benefits of modern tooling, none of the framework overhead.
Installation & Quick Start
npm install vite vite-plugin-html-pages javascript-to-html
vite.config.mjs
import { defineConfig } from 'vite';
import htmlPages from 'vite-plugin-html-pages';
export default defineConfig({
plugins: [
htmlPages({
pagesDir: 'src',
cleanUrls: true
}),
]
});
Features
- Core
- Generate static HTML from JavaScript (.ht.js / .ht.ts)
- Zero runtime by default (no hydration or framework required)
- File-based routing
- Deterministic builds (what you build is what you deploy)
- Routing
- Dynamic routes [slug]
- Multiple parameters [year]/[slug]
- Catch-all routes [...slug]
- Optional catch-all routes [...slug]?
- Route groups (admin)/users.ht.js
- Index routes blog/[slug]/index.ht.js
- Data & Scalability
- Build thousands of pages from data (APIs, JSON, files)
- Static params generation
- Fetch caching for data loading
- Parallel static generation
- Assets
- Built-in asset pipeline (JS, TS, CSS via esbuild)
- Preserves src/ directory structure in output
- public/ directory passthrough for static assets
- Root-relative URLs (/js/..., /css/..., /fonts/...) just work
- CSS url(...) resolution (with graceful fallbacks)
- Configurable missing asset handling (error or warning)
- Dev Experience
- Dev server with SSR rendering
- Automatic browser reload on file changes
- Debug logging
- Output
- Automatic 404.html
- Automatic sitemap.xml
- Optional RSS feed generation