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 Fresh · Dec 6, 2026

vite-plugin-runtime-env has 66,629 recorded weekly downloads on npm, a decrease of 43.9% over the past 30 days, ranking #714 of 3,247 tracked listings.

Weekly downloads
66,629
Official API · Dec 5, 2026
7-day growth
+71.3%
+27.7K weekly downloads
30-day growth
-43.9%
-52.1K weekly downloads
90-day growth
+74.4%
+28.4K weekly downloads
Rank
#714
▲ 105 in 7 days

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: 66,629 weekly downloads as of Dec 5, 2026, +74.4% over 90 days.vite-plugin-runtime-envWeekly downloads on npm · Last 90 days66,629downloads / week+74.4% over 90 days020K40K60K80K100K120K140KSep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
vite-plugin-runtime-env weekly downloads on npm, last 90 days: 66,629 weekly downloads as of Dec 5, 2026, +74.4% over 90 days.

7/30/90-day growth

vite-plugin-runtime-env weekly downloads growth on npm: +71.3% over 7 days, -43.9% over 30 days, +74.4% over 90 days.vite-plugin-runtime-envWeekly downloads growth on npm66,629downloads / week now7-day growth+27,737 weekly downloads+71.3%30-day growth-52,136 weekly downloads-43.9%90-day growth+28,423 weekly downloads+74.4%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
vite-plugin-runtime-env weekly downloads growth on npm: +71.3% over 7 days, -43.9% over 30 days, +74.4% over 90 days.

Ranking history

vite-plugin-runtime-env npm ranking history: currently #714 (by weekly downloads).vite-plugin-runtime-envnpm ranking · by weekly downloads · Last 90 days#714current rank#550#600#650#700#750#800#850Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 18, 2026 – Dec 6, 2026 · 44 observations · Updated Dec 5, 2026pluginstats.com
vite-plugin-runtime-env npm ranking history: currently #714 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,084 shown · page 36, #14 (overall #714)
All npm: every listing in weekly downloads order

Listing placement

Vite plugins300 listings · 15 pages · page 7, #3 (overall #123)
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 (170)
Recent weekly downloads observations for vite-plugin-runtime-env
Date (UTC)Weekly downloadsChange vs. previous
66,629+1.9K
64,736+13.2K
51,558+8.9K
42,680+2.9K
39,761+480
39,281+1.8K
37,455-1.4K
38,892-2K
40,863-4.9K
45,800-5.1K
50,949-8.9K
59,897-5.2K
65,130-6.6K
71,742—

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 Dec 6, 2026. See the methodology.