Registry / devops / vite-plugin-valibot-env

vite-plugin-valibot-env

JSON →
library1.0.2jsnpmunverified

A Vite plugin that validates environment variables against a Valibot schema at build time. Current stable version is 1.0.2, released with support for Vite 8 stable. Released under MIT license. Key differentiators: integrates Valibot's modular and lightweight schema validation, supports optional prefix stripping, value transformation (boolean, integer, float, null), localized error messages via @valibot/i18n, and callback hooks for custom issue handling. Requires Node.js 20+ and Valibot 1.0.0+. Alternative to similar plugins using Zod or Joi, offering tree-shakeable validators.

npm install vite-plugin-valibot-env
INSTALL
IMPORT
SIG · VITE-PLUGIN-VALIBO
V
vite-plugin-valibot-env
devopsjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

valibotEnv (default)
import valibot from 'vite-plugin-valibot-env'
import { valibot } from 'vite-plugin-valibot-env'
Default export, not named. Use default import.
valibotEnv (require)
const valibot = require('vite-plugin-valibot-env').default
const valibot = require('vite-plugin-valibot-env')
CommonJS require requires `.default` because the package is ESM-first; CJS via bundler fallback.
type Config (TypeScript)
import type { Config } from 'vite-plugin-valibot-env'
Type import for options object; only available if you need the exact type.

Validates environment variables against a Valibot schema, with value transformation and prefix handling.

import { defineConfig } from 'vite'; import * as v from 'valibot'; import valibotEnv from 'vite-plugin-valibot-env'; const envSchema = v.object({ VITE_API_URL: v.pipe(v.string(), v.url()), VITE_PORT: v.pipe(v.string(), v.transform(Number)), VITE_DEBUG: v.optional(v.pipe(v.string(), v.transform((s) => s === 'true'))), }); export default defineConfig({ plugins: [ valibotEnv(envSchema, { ignoreEnvPrefix: false, transformValues: true, }), ], });
Debug
Known issues
breakingIn version 0.10.0, the peer dependency requirement changed from valibot <1.0.0 to >=1.0.0. Valibot 0.x schemas are incompatible.
fix
Update Valibot to 1.0.0 or later; adjust schema syntax if needed (Valibot 1.0 breaking changes).
affects: >=0.10.0
gotchaThe default export is the plugin function, not an object with a named export. Attempting `import { valibot }` will result in `undefined`.
fix
Use default import: `import valibot from 'vite-plugin-valibot-env'`.
affects: >=0.9.0
gotchaWhen using CommonJS require (e.g., in a Node.js environment), you must use `.default` because the package is ESM-first and bundled as CJS with an export default.
fix
Use `const valibot = require('vite-plugin-valibot-env').default`.
affects: >=0.9.0
deprecatedThe `onBeforeIssues` and `onAfterIssues` callbacks are available but may be removed in future releases in favor of a unified event system.
fix
Monitor changelog for migration; currently still supported.
affects: >=0.9.0
gotchaWhen using `language` option, you must install `@valibot/i18n` separately and import it in your Vite config. The plugin does not automatically bundle i18n.
fix
Install `@valibot/i18n`, then import it in your vite.config file before using the language option.
affects: >=0.9.0
Errors
Common errors & fixes
TypeError: valibot is not a function
Using named import `import { valibot } from 'vite-plugin-valibot-env'` instead of default import.
fix
Change to `import valibot from 'vite-plugin-valibot-env'`.
Error: Cannot find module 'vite-plugin-valibot-env'
Package not installed or not in node_modules.
fix
Run `npm install vite-plugin-valibot-env valibot` or `deno add jsr:@idleberg/vite-plugin-valibot-env valibot`.
The plugin options 'language' require '@valibot/i18n' installed.
Missing `@valibot/i18n` peer dependency when using language option.
fix
Install `@valibot/i18n` with your package manager.
Error: Valibot schema version mismatch. Expected >=1.0.0 but got 0.x
Using an older version of valibot (0.x) with vite-plugin-valibot-env >=0.10.0.
fix
Upgrade valibot to ^1.0.0 and adjust schema syntax.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
valibotrequiredRuntime dependency for schema validation
viteoptionalPeer dependency — the plugin is a Vite plugin
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
vite-plugin-valibot-env — npm install vite-plugin-valibot-env · libregistry