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
- Change imports to `import { env } from '$app/env/private'`
- Keep usage of `env.VAR_NAME` identical — only the module specifier changes
- 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
- Import env exclusively from $app/env/private in server-only modules
- Add import lint rules restricting $env/* specifiers
- Grep for `$env/dynamic/private` during dependency upgrades
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
- `$env/dynamic/public` is deprecated, use `$app/env/public` i
- `$env/static/private` is deprecated, use `$app/env/private`
- `$app/environment` is deprecated, use `$app/env` instead
- Cannot import `$app/*` modules other than `$app/env` inside
- Reading `config.kit` inside adapters is deprecated — it shou
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/8e462384582ccf6d.
Report an issue: GitHub.