Skip to content
PluginStats

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.

View on npm Stale · Oct 18, 2026

vite-plugin-runtime-env has 29,779 recorded weekly downloads on npm, a decrease of 25.3% over the past 30 days, ranking #695 of 2,391 tracked listings.

Weekly downloads
29,779
Official API · Oct 18, 2026
7-day growth
-30.5%
-13.1K weekly downloads
30-day growth
-25.3%
-10.1K weekly downloads
90-day growth
+23.1%
+5.6K weekly downloads
Rank
#695
Among tracked npm listings

About vite-plugin-runtime-env

vite-plugin-runtime-env

Test Status npm License

Inject environment variables on runtime rather than build time.

Installation

npm install --save-dev vite-plugin-runtime-env

Usage

First you need to add the plugin to your vite config.

import runtimeEnv from 'vite-plugin-runtime-env';

export default defineConfig({
  plugins: [
    runtimeEnv(),
  ]
});

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 or npx envsub when deploying your app.

cp dist/index.html index.html.template
envsubst < index.html.template > dist/index.html

Or, when Node.js is available in your deployment environment:

npx envsub dist/index.html

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:

import runtimeEnv from 'vite-plugin-runtime-env';

export default defineConfig({
  plugins: [
    runtimeEnv({
        variableName: 'window.myCustomEnv',
    }),
  ]
});
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:

import runtimeEnv from 'vite-plugin-runtime-env';

export default defineConfig({
  plugins: [
    runtimeEnv({
        injectHtml: false,
    }),
  ]
});
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:

import runtimeEnv from 'vite-plugin-runtime-env';

export default defineConfig({
  plugins: [
    runtimeEnv({
        substitutionSyntax: 'handlebars',
    }),
  ]
});

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:

import runtimeEnv from 'vite-plugin-runtime-env';

export default defineConfig({
  plugins: [
    runtimeEnv({
        ignoreEnv: ['VITE_CURRENT_VERSION'],
    }),
  ]
});

Example using a function:

import runtimeEnv from 'vite-plugin-runtime-env';

export default defineConfig({
  plugins: [
    runtimeEnv({
        ignoreEnv: env => env.startsWith('VITE_STATIC_'),
    }),
  ]
});

Motivation

If your project wants to adhere to the 12 factor principles 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

vite-plugin-runtime-env weekly downloads on npm, last 90 days: 29,779 weekly downloads as of Oct 18, 2026, +23.1% over 90 days.vite-plugin-runtime-envWeekly downloads on npm · Last 90 days29,779downloads / week+23.1% over 90 days20K25K30K35K40K45K50K55K60KJul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18downloads / weekobservedarchived (Internet Archive)no observationsJul 23, 2026 – Oct 18, 2026 · 88 observations · Updated Oc…pluginstats.com
vite-plugin-runtime-env weekly downloads on npm, last 90 days: 29,779 weekly downloads as of Oct 18, 2026, +23.1% over 90 days.

7/30/90-day growth

vite-plugin-runtime-env weekly downloads growth on npm: -30.5% over 7 days, -25.3% over 30 days, +23.1% over 90 days.vite-plugin-runtime-envWeekly downloads growth on npm29,779downloads / week now7-day growth-13,094 weekly downloads-30.5%30-day growth-10,108 weekly downloads-25.3%90-day growth+5,587 weekly downloads+23.1%Growth vs. nearest observation to each baseline date · Updated Oct 18, 2026pluginstats.com
vite-plugin-runtime-env weekly downloads growth on npm: -30.5% over 7 days, -25.3% over 30 days, +23.1% over 90 days.

Ranking history

vite-plugin-runtime-env npm ranking history: currently #695 (by weekly downloads).vite-plugin-runtime-envnpm ranking · by weekly downloads · Last 90 days#695current rank#692#694#696#698#700#702Jul 23Aug 7Aug 22Sep 6Sep 21Oct 6Oct 21rankOct 18, 2026 – Oct 21, 2026 · 4 observations · Updated Oct 18, 2026pluginstats.com
vite-plugin-runtime-env npm ranking history: currently #695 (by weekly downloads).

Listing placement

All npm2,389 listings · 120 pages · 1,196 shown · page 35, #16 (overall #696)
All npm: every listing in weekly downloads order

Listing placement

Vite plugins257 listings · 13 pages · page 6, #14 (overall #114)
Vite plugins: every listing in weekly downloads order

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 (122)
Recent weekly downloads observations for vite-plugin-runtime-env
Date (UTC)Weekly downloadsChange vs. previous
29,779+4.8K
24,963-5.1K
30,092+2.5K
27,579-8.8K
36,393-11.2K
47,6210
47,621+4.7K
42,873+297
42,576+3.8K
38,728+2.3K
36,380-746
37,126-2.6K
39,678-12.4K
52,056—

Similar npm Vite plugins plugins

All 20 vite-plugin-runtime-env alternatives

Data 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 21, 2026. See the methodology.