Skip to content
PluginStats

@julr/vite-plugin-validate-env weekly downloads statistics

By julr · npm · Vite plugins

✅ Vite plugin for validating your environment variables

View on npm Fresh · Oct 18, 2026

@julr/vite-plugin-validate-env has 22,184 recorded weekly downloads on npm, a decrease of 41.6% over the past 30 days, ranking #765 of 2,322 tracked listings.

Weekly downloads
22,184
Official API · Oct 18, 2026
7-day growth
-44.9%
-18.1K weekly downloads
30-day growth
-41.6%
-15.8K weekly downloads
90-day growth
-22.3%
-6.4K weekly downloads
Rank
#765
Among tracked npm listings

About @julr/vite-plugin-validate-env

<p align="center"> <img src="https://user-images.githubusercontent.com/8337858/188329992-e74b3393-5bec-48b3-bba9-a8c45d279866.png"> </p>

vite-plugin-validate-env

A Vite plugin that validates your environment variables at build or dev time. This helps you catch misconfigurations early by failing fast. No more broken builds or 10 minutes of debugging just to realize you forgot a variable 🥲


✅ Features

  • Validate environment variables at build time only, zero runtime overhead
  • Fully type-safe
  • Supports standard-schema — works with Zod, Valibot, ArkType, and more
  • Built-in parsing, validation, and transformation
  • Custom rules and error messages

Installation

pnpm add -D @julr/vite-plugin-validate-env

Basic Usage

You can use the plugin with the built-in validator for simple use cases, or with libraries like Zod for more advanced schemas.

[!TIP] I would recommend using a dedicated env.ts file to keep your Vite config clean and separate from your environment variable definitions. See the Using a Dedicated env.ts Config File section for more details.

Built-in Validator
// vite.config.ts
import { defineConfig } from 'vite'
import { Schema, ValidateEnv } from '@julr/vite-plugin-validate-env'

export default defineConfig({
  plugins: [
    ValidateEnv({
      validator: 'builtin',
      schema: {
        VITE_MY_VAR: Schema.string(),
      },
    }),
  ],
})
Standard Schema Validators

If you want to use Zod or another validator compatible with standard-schema, pass the validator and schema manually:

import { defineConfig } from 'vite'
import { z } from 'zod'
import { ValidateEnv } from '@julr/vite-plugin-validate-env'

export default defineConfig({
  plugins: [
    ValidateEnv({
      validator: 'standard', // 👈
      schema: {
        VITE_MY_VAR: z.string(),
      },
    }),
  ],
})

Built-in Validator Examples

ValidateEnv({
  VITE_STRING: Schema.string(),
  VITE_NUMBER: Schema.number(),
  VITE_BOOLEAN: Schema.boolean(),
  VITE_ENUM: Schema.enum(['foo', 'bar'] as const),

  // Optional
  VITE_OPTIONAL: Schema.boolean.optional(),

  // With format and protocol checks
  VITE_API_URL: Schema.string({ format: 'url', protocol: true }),

  // With custom error message
  VITE_PORT: Schema.number({ message: 'You must set a port!' }),

  // Custom validator + transform function
  VITE_URL_SUFFIXED_WITH_SLASH: (key, value) => {
    if (!value) throw new Error(`Missing ${key}`)

    return value.endsWith('/') ? value : `${value}/`
  },
})

Using Standard Schema

standard-schema provides a common interface for multiple validation libraries.

Here’s how to use it with Zod, Valibot, or ArkType, or any other library that supports it.

import { defineConfig } from '@julr/vite-plugin-validate-env'
import { z } from 'zod'
import * as v from 'valibot'
import { type } from 'arktype'

export default defineConfig({
  validator: 'standard',
  schema: {
    VITE_ZOD_VAR: z.string(),
    VITE_VALIBOT_VAR: v.string(),
    VITE_ARKTYPE_VAR: type.string(),
  },
})

Using a Dedicated env.ts Config File

You can move your env definitions to a separate file like this:

// vite.config.ts
import { defineConfig } from 'vite'
import { ValidateEnv } from '@julr/vite-plugin-validate-env'

export default defineConfig({
  plugins: [
    ValidateEnv({
      // Optional: you can specify a custom path for the config file
      configFile: 'config/env',
    }),
  ],
})
// env.ts
import { defineConfig, Schema } from '@julr/vite-plugin-validate-env'

export default defineConfig({
  validator: 'builtin',
  schema: {
    VITE_MY_VAR: Schema.enum(['foo', 'bar'] as const),
  },
})

Typing import.meta.env

In order to have a type-safe import.meta.env, the ideal is to use the dedicated configuration file env.ts. Once this is done, you would only need to add an vite-env.d.ts in src/ folder to augment ImportMetaEnv (as suggested here ) with the following content:

/// <reference types="vite/client" />

type ImportMetaEnvAugmented = import('@julr/vite-plugin-validate-env').ImportMetaEnvAugmented<
  typeof import('../env').default
>

interface ViteTypeOptions {
  // Avoid adding an index type to `ImportMetaDev` so
  // there's an error when accessing unknown properties.
  // ⚠️ This option requires Vite 6.3.x or higher
  strictImportMetaEnv: unknown
}

interface ImportMetaEnv extends ImportMetaEnvAugmented {
  // Now import.meta.env is totally type-safe and based on your `env.ts` schema definition
  // You can also add custom variables that are not defined in your schema
}

Validation without Vite

In some cases, you might want to validate environment variables outside of Vite and reuse the same schema. You can do so by using the loadAndValidateEnv function directly. This function will validate and also load the environment variables inside the process.env object.

[!WARNING] process.env only accept string values, so don't be surprised if a number or boolean variable comes back as a string when accessing it after validation.

import { loadAndValidateEnv } from '@julr/vite-plugin-validate-env'

const env = await loadAndValidateEnv(
  {
    mode: 'development', // required
    root: import.meta.dirname, // optional
  },
  {
    // Plugin options. Also optional if you
    // are using a dedicated `env.ts` file
    validator: 'builtin',
    schema: { VITE_MY_VAR: Schema.string() },
  },
)

console.log(env.VITE_MY_VAR)
console.log(process.env.VITE_MY_VAR)

💖 Sponsors…

Description from the npm listing.

  • env
  • env-var
  • validation
  • vite
  • vite-plugin
  • zod

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

@julr/vite-plugin-validate-env weekly downloads on npm, last 90 days: 22,184 weekly downloads as of Oct 18, 2026, -22.3% over 90 days.@julr/vite-plugin-validate-envWeekly downloads on npm · Last 90 days22,184downloads / week-22.3% over 90 days010K20K30K40K50K60KJul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18downloads / weekobservedarchived (Internet Archive)no observationsJul 22, 2026 – Oct 18, 2026 · 89 observations · Updated Oc…pluginstats.com
@julr/vite-plugin-validate-env weekly downloads on npm, last 90 days: 22,184 weekly downloads as of Oct 18, 2026, -22.3% over 90 days.

7/30/90-day growth

@julr/vite-plugin-validate-env weekly downloads growth on npm: -44.9% over 7 days, -41.6% over 30 days, -22.3% over 90 days.@julr/vite-plugin-validate-envWeekly downloads growth on npm22,184downloads / week now7-day growth-18,056 weekly downloads-44.9%30-day growth-15,779 weekly downloads-41.6%90-day growth-6,383 weekly downloads-22.3%Growth vs. nearest observation to each baseline date · Updated Oct 18, 2026pluginstats.com
@julr/vite-plugin-validate-env weekly downloads growth on npm: -44.9% over 7 days, -41.6% over 30 days, -22.3% over 90 days.

Ranking history

@julr/vite-plugin-validate-env npm ranking history: currently #765 (by weekly downloads).@julr/vite-plugin-validate-envnpm ranking · by weekly downloads · Last 90 days#765current rank#200#300#400#500#600#700#800Jul 22Aug 6Aug 21Sep 5Sep 20Oct 5Oct 20rankOct 17, 2026 – Oct 20, 2026 · 4 observations · Updated Oct 18, 2026pluginstats.com
@julr/vite-plugin-validate-env npm ranking history: currently #765 (by weekly downloads).

Listing placement

All npm2,320 listings · 116 pages · 1,162 shown · page 39, #6 (overall #766)
All npm: every listing in weekly downloads order

Listing placement

Vite plugins253 listings · 13 pages · page 7, #8 (overall #128)
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 (544)
Recent weekly downloads observations for @julr/vite-plugin-validate-env
Date (UTC)Weekly downloadsChange vs. previous
22,184+4.2K
18,002-2.4K
20,355+228
20,127-10.1K
30,232-8.7K
38,9400
38,940-1.3K
40,240-176
40,416+355
40,061+970
39,091+1.3K
37,836-1.1K
38,955-10.5K
49,475—

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/@julr/vite-plugin-validate-env. First seen Oct 16, 2026; last successful collection Oct 20, 2026. See the methodology.