Vite Envs screenshot

Vite Envs

Author Avatar Theme by Garronej
Updated: 3 Jul 2025
78 Stars

Env var in Vite at container startup

Categories

Overview

Vite has become a popular choice for building fast and efficient web applications, and with the introduction of vite-envs, the deployment process has been streamlined considerably. This innovative tool allows developers to dynamically define environment variables without the need for constant rebuilding, making it easier to customize applications according to deployment needs. With vite-envs, web apps can be shipped as customizable Docker images, providing flexibility for sysadmins and ensuring a seamless deployment experience.

By integrating effortlessly into existing projects and enhancing Vite’s capabilities, vite-envs empowers developers to create more dynamic and responsive applications. The convenience of accessing environment variables right from the HTML and TypeScript files elevates the development workflow while maintaining security and type safety.

Features

  • Effortless Setup: Integrates smoothly into existing Vite projects without disrupting Storybook or other configurations.
  • No VITE_ Prefix Necessary: Simplifies the environment variable access by eliminating the need for the standard prefix.
  • Type-Safe: Provides type definitions for import.meta.env, ensuring a robust development experience with hot reload capabilities.
  • Dynamic HTML Usage: Allows the use of environment variables directly in HTML files, e.g., <title>%FOO%</title>.
  • Computed Values at Build Time: Supports calculations of environment values at build time for added flexibility.
  • EJS Expression Support: Optionally enables EJS expressions in your index.html, making it possible to manipulate variables directly in HTML.
  • Secure Variable Injection: Only injects explicitly defined environment variables from the .env file, ensuring a secure build process.
  • Custom Declaration Files: Offers the ability to declare variables in an alternative file like .env.declaration if .env is gitignored, catering to different project needs.