sveltejs/kit · warning

`$env/dynamic/private` is deprecated, use `$app/env/private`

Error message

`$env/dynamic/private` is deprecated, use `$app/env/private` instead

What it means

The `$env/dynamic/private` module is deprecated; it re-exports the environment from the new `$app/env/private` location and emits this DEV warning at import time. Dynamic private environment variables are still available, but you should import from the new module. Existing behavior is unchanged aside from the warning.

Source

Thrown at packages/kit/src/runtime/env/dynamic/private.js:6

import { DEV } from 'esm-env';
import * as env from '../../app/env/private/index.js';
export { env };

if (DEV) {
	console.warn('`$env/dynamic/private` is deprecated, use `$app/env/private` instead');
}

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Change imports to `import { env } from '$app/env/private'`
  2. Keep usage of `env.VAR_NAME` identical — only the module specifier changes
  3. Update shared server utilities that re-export from `$env/dynamic/private`

Example fix

// before
import { env } from '$env/dynamic/private';
// after
import { env } from '$app/env/private';
Defensive patterns

Strategy: validation

Validate before calling

import { env } from '$app/env/private'; // only ever import env from $app/env/*
if (DEV && process.env.SVELTEKIT_ENV_CHECK) console.assert(!envModulesUseLegacy, 'legacy $env/dynamic/private import');

Prevention

When it happens

Trigger: Importing `import { env } from '$env/dynamic/private'` (or importing the module at all) in server-only code during development.

Common situations: Server code (hooks, +server.ts, endpoints) written against the older env module path; upgrades to the SvelteKit version that introduced `$app/env` modules.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/8e462384582ccf6d. Report an issue: GitHub.