vite-plugin-runtime-env weekly downloads statistics
By micha149 · npm · Vite plugins
Vite plugin which enables you to configure your environment variables when deploying your app.
vite-plugin-runtime-env has 24,963 recorded weekly downloads on npm, a decrease of 39.6% over the past 30 days, ranking #699 of 2,256 tracked listings.
About vite-plugin-runtime-env
vite-plugin-runtime-env
Inject environment variables on runtime rather than build time.
Installation
Usage
First you need to add the plugin to your vite config.
When building your app, the plugin replaces all occurrences of import.meta.env.VITE_MY_VARIABLE with something like window.env.VITE_MY_VARIABLE and inserts a mapping into index.html. The mapping contains placeholder variables like ${VITE_MY_VARIABLE} which can be substituted using [envsubst][envsubst] or [npx envsub][envsub] when deploying your app.
Or, when Node.js is available in your deployment environment:
Both examples assume that your variables are defined in the deploy environment. The node tool also supports .env files as arguments.
Configuration
variableName
The variable name to be used for replacements. Defaults to 'window.env'.
Example:
injectHtml
Whether to inject the variables map into index.html. Sometimes it can be handy to not have the map in index.html and load an external javascript file which sets the object. Defaults to true.
Example:
substitutionSyntax
The syntax for inserted placeholders. This should match the tool you are using to substitute the variables on deployment. Valid values are 'dollar-basic' for $MYVAR, 'dollar-curly' for ${MYVAR} and 'handlebars' for {{MYVAR}}. Defaults to 'dollar-curly'.
Example:
Now you can use a custom script using handlebars to inject the variables.
ignoreEnv
Variable names to be ignored by this plugin. They will remain in the code and will be statically replaced by Vite on build time. This can be useful for information which is known on build time and not configurable on runtime, such as the version number of the current build. Valid values are an array of strings, containing the variables to be ignored, or a function which gets each variable as an input and returns true if the variable should be skipped.
Example:
Example using a function:
Motivation
If your project wants to adhere to the [12 factor principles][12factor] it can be cumbersome that Vite replaces your environment variables with static content on build time. Following the principle "I – Config" we want to store configurations in the environment. And funnily enough, this is also implied by the name "environment variable". Respecting these principles can be useful when running your app in a containerized setup like Docker or Kubernetes.
A workaround would be to run vite build when deploying the app. But this may slow down our deployments, especially when deploying multiple instances and each one builds the app for its own. Also, this would be contrary to principle "V – Build, release, run" which requires strict separation between the build, release, and run stages.
To be able to create a single bundle and run the same bundle in different environments like testing, staging and production, we need to be able to pass some configurations when the app is deployed. After a lot of projects where each solves this same problem with its own custom workaround, I created this plugin to rule them all.
Description from the npm listing.
- docker
- environment
- 12-factor
- vite
- dot-env
- vite-plugin
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 vite-plugin-runtime-env 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-plugin-runtime-env. First seen Oct 16, 2026; last successful collection Oct 19, 2026. See the methodology.