0Pricing
Sveltejs Academy · Lesson

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

  1. CSRF Protection in Form Actions
  2. XSS Prevention in {#html}
  3. Environment Variables: $env/static and $env/dynamic
  4. Rate Limiting with Hooks
← Back to Sveltejs Academy