Skip to main content

$env/static/private

Environment variables loaded by Vite from .env files and process.env. Like $env/dynamic/private, this module cannot be imported into client-side code. This module only includes variables that do not begin with config.kit.env.publicPrefix and do start with config.kit.env.privatePrefix (if configured).

Unlike $env/dynamic/private, the values exported from this module are statically injected into your bundle at build time, enabling optimisations like dead code elimination.

import { import API_KEYAPI_KEY } from '$env/static/private';

Note that all environment variables referenced in your code should be declared (for example in an .env file), even if they don’t have a value until the app is deployed:

MY_FEATURE_FLAG=""

You can override .env values from the command line like so:

MY_FEATURE_FLAG="enabled" npm run dev

Edit this page on GitHub