vite-react-ssg weekly downloads statistics
By Daydreamer-riri · npm · Vite plugins
Static-site generation for React on Vite.
vite-react-ssg has 19,264 recorded weekly downloads on npm, a decrease of 58.6% over the past 30 days, ranking #764 of 2,256 tracked listings.
About vite-react-ssg
Vite React SSG
Static-site generation for React on Vite.
See demo(also document): docs
[!IMPORTANT] React Router v7 Notice
React Router v7 now has built-in SSG support. If you are using React Router v7, we recommend using its official SSG capabilities for better official support and integration.
vite-react-ssg will continue to maintain SSG functionality for React Router v6 users.
🎈 Support for @tanstack/router and wouter is in progress!
Support for the @tanstack/router router is still experimental, and pathname.lazy.tsx routes are not yet supported. For usage examples, see: main/examples/tanstack/src/main.tsx
Table of contents
• Usage • Use CSR during development • Extra route options • entry • getStaticPaths • Data fetch • lazy • • Document head • Reactive head • Redirect • Public Base Path • Future config • CSS in JS • Critical CSS • Configuration • Custom Routes to Render • Roadmap • Credits
Usage
npm i -D vite-react-ssg react-router-dom
Use CSR during development
Vite React SSG provide SSR (Server-Side Rendering) during development to ensure consistency between development and production as much as possible.
But if you want to use CSR during development, just:
Single Page SSG
For SSG of an index page only (i.e. without react-router-dom); import vite-react-ssg/single-page instead.
Extra route options
The RouteObject of vite-react-ssg is based on react-router, and vite-react-ssg receives some additional properties.
getStaticPaths
The getStaticPaths() function should return an array of path to determine which paths will be pre-rendered by vite-react-ssg.
This function is only valid for dynamic route.
entry
You are not required to use this field. It is only necessary when "prehydration style loss" occurs. It should be the path from root to the target file.
eg: src/pages/page1.tsx
lazy
These options work well with the lazy field.
Note that during the build process, vite-react-ssg will automatically detect the files directly dynamically imported in the function you pass to the lazy field. This helps vite-react-ssg to get the route's style files or other static resources during the build, preventing flash of unstyled content.
If you still encounter FOUC (flash of unstyled content), please open an issue.
If your component isn't loading, make sure you have wrapped it or its parent in Suspense tags as described in the React documentation.
See example.
Data fetch
You can use react-router-dom's loader to fetch data at build time and use useLoaderData to get the data in the component.
In production, the loader will only be executed at build time, and the data will be fetched by the manifest generated at build time during the browser navigations .
In the development environment, the loader also runs only on the server.It provides data to the HTML during initial server rendering, and during browser route navigations , it makes calls to the server by initiating a fetch on the service.
See example | with-loader.
If you need to render some component in browser only, you can wrap your component with .
It's important that the children of is not a JSX element, but a function that returns an element. Because React will try to render children, and may use the client's API on the server.
Document head
You can use to manage all of your changes to the document head. It takes plain HTML tags and outputs plain HTML tags. It is a wrapper around React Helmet.
Nested or latter components will override duplicate usages:
Outputs:
Reactive head
Redirect
You should not use redirect in the loader. In vite-react-ssg, the loader only executes during the build process for data fetching. If you need to perform a redirect in certain situations, you can use the following method to redirect on the client side:
Public Base Path
Just set base in vite.config.ts like:
Vite React SSG will give it to the react-router's basename.
See: react-router's create-browser-router
Example
Future config
See: react-router's optsfuture
Example
Custom Router Factory
You can provide a custom router factory function via customCreateRouter option. This is useful if you want to use a different router implementation or wrap the default createBrowserRouter.
eg. sentry
CSS in JS
Use the getStyleCollector option to specify an SSR/SSG style collector. Currently only supports styled-components.
You can provide your own by looking at the implementation of any of the existing collectors.
Critical CSS
Vite React SSG has built-in support for generating Critical CSS inlined in the HTML via the beasties package. Install it with:
Critical CSS generation will automatically be enabled for you.
To configure beasties, pass its options into ssgOptions.beastiesOptions in vite.config.ts:
Configuration
You can pass options to Vite SSG in the ssgOptions field of your vite.config.js
See src/types.ts. for more options available.
Custom Routes to Render
You can use the includedRoutes hook to include or exclude route paths to render, or even provide some completely custom ones.
React17 Support
• for react18, with flag useLegacyRender: true, it will use the legacy render and hydrate methods. • for react17, on top of above, you will need minor update to react and react-dom example to polyfill the mjs import and the react-dom/client.
Roadmap
• [x] Support react19 • [ ] no index.html mode
Credits
This project inspired by vite-ssg, thanks to @antfu for his awesome work.
License
MIT License © 2023 Riri
Description from the npm listing.
- vite
- vite-plugin
- ssg
- ssr
- react
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 (543)Similar npm Vite plugins plugins
All 20 vite-react-ssg 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/vite-react-ssg. First seen Oct 16, 2026; last successful collection Oct 19, 2026. See the methodology.