0Pricing
Sveltejs Academy · Lesson

+page.js load Function

Export a load function to fetch or compute data before the page renders.

Why Load Functions

SvelteKit needs to know what data your page needs so it can fetch before render. The load function provides it.

File Location

Create +page.js next to +page.svelte in the same folder.

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