Vite plugin to preprocess HTML files with Handlebars templates during development and build. Current stable version 2.0.3 supports Vite 5, 6, 7, and 8. It injects context data, partials, and helpers into HTML files via `?handlebars` query or default HTML processing. Differentiates from generic Vite HTML transforms by providing Handlebars-specific integration with low configuration overhead. Requires Vite ≥5.
npm install vite-plugin-handlebarsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configures Vite with Handlebars plugin, providing context data, partials, helpers, and compile options.
Upgrade Vite to ^5.0.0 or stay on vite-plugin-handlebars v1.x.
Use default import: `import handlebars from 'vite-plugin-handlebars'`.
Use absolute paths or paths relative to process.cwd(), typically root of Vite project.
Ensure context data is serializable (plain objects, arrays, strings, numbers).
Pass helpers as an object where keys are helper names, values are helper functions.
Run `npm install vite-plugin-handlebars@latest` and ensure Vite >=5.
Provide an object: `context: { key: 'value' }`.Check that partial file exists at the given path relative to project root.
Review template syntax; test with Handlebars standalone.
Upgrade Vite or install previous major version: `npm install vite-plugin-handlebars@1`.