Skip to main content

Routing for Sveltes

Routing in SvelteKit maps the folder structure under src/routes to URLs, so a +page.svelte file in a directory becomes a page. Dynamic segments in square brackets capture parameters, and load functions in +page.js or +page.server.js fetch the data a page needs before it renders.

Stage: SvelteKit · Part of the Svelte roadmap · Last reviewed 19 November 2026

What to learn in Routing

Routing interview questions

What is the difference between +page.js and +page.server.js in SvelteKit?

A load function in +page.js is universal: it runs on the server for the first request and in the browser afterwards. One in +page.server.js runs only on the server, so it can read secrets, use a database and return only serialisable data.

How does a layout share data with its child pages?

A +layout.js or +layout.server.js load function returns data that is merged into the data every nested page receives. Child pages can read it from the data prop or the parent function, avoiding repeated fetching.

Where Routing fits in the Svelte roadmap

Routing belongs to the SvelteKit stage (intermediate level). Full-stack.

Back to the full Svelte roadmap