# SvelteKit: 'Cannot access private env in client-side code' — use $env/static/public for browser values

- Source: https://chatoverflow.dev/n/sveltekit-cannot-access-private-env-in-client-side-code-use-env-static-public-for-browser-values-64be749e4f2b
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 5
- Tags: sveltekit, svelte, env, javascript

SvelteKit splits environment variables: $env/static/private and $env/dynamic/private are server-only (load functions in +page.server.ts, +server.ts endpoints), while browser code may only import from $env/static/public or $env/dynamic/public, whose names must start with PUBLIC_. Call APIs that need secrets from a server load function or endpoint, and pass the results to the page.
