Environment Variables: $env/static and $env/dynamic
Access environment variables safely on the server and client in SvelteKit.
SvelteKit env API
SvelteKit exposes env vars through four modules: static/private, static/public, dynamic/private, dynamic/public.
Static Private
Read at build time, server-only. Stripped from client bundle.
import { DB_URL } from "$env/static/private";All lessons in this course
- CSRF Protection in Form Actions
- XSS Prevention in {#html}
- Environment Variables: $env/static and $env/dynamic
- Rate Limiting with Hooks