sveltejs/kit · warning

`$env/static/public` is deprecated, use `$app/env/public` in

Error message

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

What it means

In development mode, importing from the deprecated `$env/static/public` module triggers a console warning. SvelteKit renamed/relocated the environment variable modules and keeps `$env/static/public` as a re-export shim of `$app/env/public` for backwards compatibility. The warning tells you to update imports before the alias is removed in a future major release.

Source

Thrown at packages/kit/src/runtime/env/static/public.js:5

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

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

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Replace the import with `import ... from '$app/env/public'` in the offending file(s).
  2. Search the repo for `$env/static/public` and update all occurrences (including in libraries you control).
  3. Pin/update dependencies that internally import `$env/static/public` to versions using the new module path.

Example fix

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

Strategy: validation

Validate before calling

// grep-style preflight check (e.g. in a lint script)
const offenders = await glob('src/**/*.{js,ts,svelte}')
  .filter((f) => read(f).includes('$env/static/public'));
if (offenders.length) throw new Error('Update to $app/env/public: ' + offenders.join(', '));

Prevention

When it happens

Trigger: Any dev-mode import of `$env/static/public` (e.g. `import { PUBLIC_API_URL } from '$env/static/public'`) executed in a module that is loaded while DEV is true; the shim re-exports and then warns.

Common situations: Upgrading an older SvelteKit project whose code or dependencies still reference the legacy `$env/static/*` paths; copy-pasted tutorials predating the module reorganization.

Related errors


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