runtime-env-vite-plugin
Guidance on using runtime-env with Vite to distinguish between runtime and build-time environment variables.
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
runtime-env-vite-plugin
This skill ensures that environment variables are handled correctly in Vite projects by distinguishing between build-time (static) variables and runtime (dynamic) variables. It enforces a sequential workflow to ensure proper analysis and clean implementation.
When to apply
You MUST apply this skill when:
- Setting up a new Vite project that requires environment variables.
- Refactoring an existing Vite project to use runtime environment variables.
- Adding new environment variables to a project already using
@runtime-env/vite-plugin.
Execution Sequence
This skill MUST be executed in the following order. Do not skip steps:
- 01 - Setup: Infrastructure, installation, and initial configuration.
- 02 - Discovery: Analyzing the codebase to identify variables and their true types (The "Think" phase).
- 03 - Migration: Applying the schema and updating the source code (The "Act" phase).
Pattern Guides
-
The String Trap: How to avoid manual parsing and leverage
runtimeEnvfor type safety.
Core Mandates
- Never assume a variable is a string just because it was one in a legacy file. Always perform discovery.
-
Always remove manual parsing logic (
parseInt,JSON.parse) during migration. -
Always run
npx runtime-env gen-tsafter updating the schema. -
Always place the script tag in
index.htmlbefore the app entry point.
Strict Prohibitions
-
NEVER use the
defaultkeyword in.runtimeenvschema.json. All environment values must originate from the environment. -
NEVER modify or delete existing
.envfiles. They are read-only sources of truth. -
NEVER add
import { runtimeEnv } from ...or similar.runtimeEnvis a global. -
NEVER add redundant
gen-tsorgen-jsscripts topackage.json.
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-03-11
- Index updated
- 2026-03-11
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!