0Pricing
Sveltejs Academy · Lesson

Universal vs Server-Only load

Understand when load runs on both client and server versus server only.

Universal vs Server-Only load is a free Sveltejs Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Sveltejs Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Two Load Files

SvelteKit supports two flavors: +page.js (universal) and +page.server.js (server-only).

Universal load

Runs on both server (initial SSR) and client (subsequent navigations).

Server load

Always runs on the server. Code and imports are stripped from client bundle.

When to Use Server

Database queries, secret keys, server-only APIs, file system access.

When to Use Universal

Public API calls that work the same in both environments.

Both at Once

You can have both files; server load runs first, then universal load can use its result.

Type Inference

Types flow automatically. The page sees the merged data type.

Performance

Server load avoids exposing API logic to clients; universal load avoids server cost on navigations.

Security

Never put secrets in universal load. The bundler will inline them into the client bundle.

Form Actions

Form actions live in +page.server.js alongside server load.

Environment Variables

Use $env/static/private only in server files to keep secrets safe.

Quick Check

Where do you put database queries?

Recap

Use +page.server.js for server-only logic (DB, secrets); +page.js for universal logic that runs on both sides.

Frequently asked questions

Is the “Universal vs Server-Only load” lesson free?

Yes — the full text of “Universal vs Server-Only load” is free to read here on the web, and the Sveltejs Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Sveltejs Academy course, upgrade to CoddyKit PRO.

What will I learn in “Universal vs Server-Only load”?

Understand when load runs on both client and server versus server only. You practise Sveltejs Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Sveltejs Academy?

No prior experience is required. Sveltejs Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Universal vs Server-Only load” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Sveltejs Academy lesson?

Yes. Every Sveltejs Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Universal vs Server-Only load
  2. prerender = true for Static Pages
  3. ssr = false for Client-Only Pages
  4. Island Architecture
← Back to Sveltejs Academy