{"id":26602,"library":"vite-plugin-valibot-env","title":"vite-plugin-valibot-env","description":"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.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/idleberg/vite-plugin-valibot-env","tags":["javascript","vite-plugin","valibot","typescript"],"install":[{"cmd":"npm install vite-plugin-valibot-env","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-valibot-env","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-valibot-env","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for schema validation","package":"valibot","optional":false},{"reason":"Peer dependency — the plugin is a Vite plugin","package":"vite","optional":true}],"imports":[{"note":"Default export, not named. Use default import.","wrong":"import { valibot } from 'vite-plugin-valibot-env'","symbol":"valibotEnv (default)","correct":"import valibot from 'vite-plugin-valibot-env'"},{"note":"CommonJS require requires `.default` because the package is ESM-first; CJS via bundler fallback.","wrong":"const valibot = require('vite-plugin-valibot-env')","symbol":"valibotEnv (require)","correct":"const valibot = require('vite-plugin-valibot-env').default"},{"note":"Type import for options object; only available if you need the exact type.","wrong":"","symbol":"type Config (TypeScript)","correct":"import type { Config } from 'vite-plugin-valibot-env'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport * as v from 'valibot';\nimport valibotEnv from 'vite-plugin-valibot-env';\n\nconst envSchema = v.object({\n  VITE_API_URL: v.pipe(v.string(), v.url()),\n  VITE_PORT: v.pipe(v.string(), v.transform(Number)),\n  VITE_DEBUG: v.optional(v.pipe(v.string(), v.transform((s) => s === 'true'))),\n});\n\nexport default defineConfig({\n  plugins: [\n    valibotEnv(envSchema, {\n      ignoreEnvPrefix: false,\n      transformValues: true,\n    }),\n  ],\n});","lang":"typescript","description":"Validates environment variables against a Valibot schema, with value transformation and prefix handling."},"warnings":[{"fix":"Update Valibot to 1.0.0 or later; adjust schema syntax if needed (Valibot 1.0 breaking changes).","message":"In version 0.10.0, the peer dependency requirement changed from valibot <1.0.0 to >=1.0.0. Valibot 0.x schemas are incompatible.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Use default import: `import valibot from 'vite-plugin-valibot-env'`.","message":"The default export is the plugin function, not an object with a named export. Attempting `import { valibot }` will result in `undefined`.","severity":"gotcha","affected_versions":">=0.9.0"},{"fix":"Use `const valibot = require('vite-plugin-valibot-env').default`.","message":"When 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.","severity":"gotcha","affected_versions":">=0.9.0"},{"fix":"Monitor changelog for migration; currently still supported.","message":"The `onBeforeIssues` and `onAfterIssues` callbacks are available but may be removed in future releases in favor of a unified event system.","severity":"deprecated","affected_versions":">=0.9.0"},{"fix":"Install `@valibot/i18n`, then import it in your vite.config file before using the language option.","message":"When using `language` option, you must install `@valibot/i18n` separately and import it in your Vite config. The plugin does not automatically bundle i18n.","severity":"gotcha","affected_versions":">=0.9.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change to `import valibot from 'vite-plugin-valibot-env'`.","cause":"Using named import `import { valibot } from 'vite-plugin-valibot-env'` instead of default import.","error":"TypeError: valibot is not a function"},{"fix":"Run `npm install vite-plugin-valibot-env valibot` or `deno add jsr:@idleberg/vite-plugin-valibot-env valibot`.","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'vite-plugin-valibot-env'"},{"fix":"Install `@valibot/i18n` with your package manager.","cause":"Missing `@valibot/i18n` peer dependency when using language option.","error":"The plugin options 'language' require '@valibot/i18n' installed."},{"fix":"Upgrade valibot to ^1.0.0 and adjust schema syntax.","cause":"Using an older version of valibot (0.x) with vite-plugin-valibot-env >=0.10.0.","error":"Error: Valibot schema version mismatch. Expected >=1.0.0 but got 0.x"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}