Skip to content
Discussion options

You must be logged in to vote

You are 100% correct :) That's what these files are used for.
When you create the route leages/[league_id] sveltekit checks if the param exists on it´s own. If so, it runs the load function inside +page.server.ts in that folder to load the data you need in your +page.svelte file next to it.

The main idea is: put the data as close to the ui/page that needs it.
Global state like authentication should go into the root layout, but even that can be optimized with advanced layouts.
Try to always use the the closest load function to your page you are rendering and move the data up towards the root layout when you have to.

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@david-plugge
Comment options

@david-plugge
Comment options

@JimNayzium
Comment options

@david-plugge
Comment options

@JimNayzium
Comment options

Answer selected by teemingc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants