@preact/preset-vite weekly downloads statistics
By preact · npm · Vite plugins
Preact preset for the vite bundler
@preact/preset-vite has 367,817 recorded weekly downloads on npm, a decrease of 31.8% over the past 30 days, ranking #280 of 2,256 tracked listings.
About @preact/preset-vite
@preact/preset-vite
An all in one preset for writing Preact apps with the vite bundler.
Features:
• Sets up Hot Module Replacement via prefresh • Enables Preact Devtools bridge during development • Aliases React to preact/compat
If you want to look into testing Preact with Vitest Browser mode check out vitest-browser-preact
Installation
First intall the preset package from npm:
Enhance your vite config with the Preact preset plugin in your vite.config.ts or vite.config.js:
Options
Options can be passed to our preset plugin via the first argument:
Available options
| Option | Type | Default | Description |
| devtoolsInProd | boolean | false | Inject devtools bridge in production bundle instead of only in development mode | | devToolsEnabled | boolean | true | Inject devtools bridge | | prefreshEnabled | boolean | true | Inject Prefresh for HMR | | reactAliasesEnabled | boolean | true | Aliases react, react-dom to preact/compat | | babel | object | | See Babel configuration | | prerender | object | | See Prerendering configuration |
Babel configuration
The babel option lets you add plugins, presets, and other configuration to the Babel transformation performed on each JSX/TSX file.
Prerendering configuration
| Option | Type | Default | Description |
| enabled | boolean | false | Enables prerendering | | renderTarget | string | "body" | Query selector for where to insert prerender result in your HTML template | | prerenderScript | string | undefined | Absolute path to script containing exported prerender() function. If not provided, will try to find the prerender script in the scripts listed in your HTML entrypoint | | additionalPrerenderRoutes | string[] | undefined | Prerendering will crawl your site automatically, but you'd like to prerender some pages that may not be found (such as a /404 page), use this option to specify them | | previewMiddlewareEnabled | boolean | false | Vite's preview server as of v5 will not use our prerendered HTML documents automatically. This option enables a middleware that will correct this, allowing you to test the result of prerendering locally | | previewMiddlewareFallback | string | /index.html | Fallback path to be used when an HTML document cannot be found via the preview middleware, e.g., /404 or /not-found will be used when the user requests /some-path-that-does-not-exist |
To prerender your app, you'll need to do these things: 1. Enable prerendering in the plugin options 2. Specify your render target, if you want the HTML to be inserted anywhere other than the document.body. This location likely should match render(), i.e., render(, document.querySelector('#app')) -> '#app' 4. Create and export a prerender() function from a script. You could add this to your app entrypoint or create a completely separate file for it, either will work. See below for a usage example 5. Specify where your prerender() function is by either a) adding a prerender attribute to the script tag that contains it in your entry HTML () or b) use the prerenderScript plugin option to specify the location with an absolute path
The plugin simply calls the prerender function you provide so it's up to you to determine how your app should be prerendered. You'll likely want to use preact-render-to-string, or a wrapper around it such as preact-iso's prerender, but whatever you choose, the minimum you'll need to return is an object containing an html property with your HTML string which will then be inserted according to your renderTarget.
Your prerender() function can be asynchronous, so feel free to make HTTP requests to retrieve data (fetch(...)), read files from disk (fs.readFile(...)), or similar things to set up your app.
For a full example implementation, see our demo
License
MIT, see the license file.
Description from the npm listing.
- preact
- vite
- vite-plugin
- vite-preset
- preset
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (121)Similar npm Vite plugins plugins
All 20 @preact/preset-vite alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/@preact/preset-vite. First seen Oct 16, 2026; last successful collection Oct 19, 2026. See the methodology.