0Pricing
Sveltejs Academy · Lesson

+page.server.js for Server-Only Logic

Keep secrets and database calls on the server by using +page.server.js.

Why Server-Only

Some data must stay on the server: database calls, secret API keys, file system access.

File Name

Use +page.server.js instead of +page.js.

All lessons in this course

  1. +page.js load Function
  2. Returning Data and Using $page.data
  3. Error Handling in load
  4. +page.server.js for Server-Only Logic
← Back to Sveltejs Academy