sveltejs/kit · warning

`$env/dynamic/public` is deprecated, use `$app/env/public` i

Error message

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

What it means

The `$env/dynamic/public` module is deprecated in favor of `$app/env/public`. The module re-exports the same public dynamic environment object and prints this DEV warning when imported. Functionality is otherwise unchanged; only the import path should move.

Source

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

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

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

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Change imports to `import { env } from '$app/env/public'`
  2. Leave `env.VAR_NAME` accesses as-is
  3. Update re-export barrels or shared config modules referencing the old path

Example fix

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

Strategy: validation

Validate before calling

import { env } from '$app/env/public'; // correct specifier
// CI grep: ! grep -r "\$env/dynamic/public" src/

Prevention

When it happens

Trigger: Importing `import { env } from '$env/dynamic/public'` anywhere in client or shared code during development.

Common situations: Client components reading public env (e.g. API keys, feature flags) via the old specifier; codebases updated to a SvelteKit version that renamed env modules under `$app/env`.

Related errors


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