Basic Routing in Svelte

From the SvelteKit cheat sheet ยท Routing ยท verified Jul 2026

Basic Routing

File-based routing patterns

javascript
// Route file structure
src/routes/
  +page.svelte       // index (/)
  +layout.svelte     // root layout
  about/+page.svelte // /about
  blog/
    +page.svelte     // /blog
    [slug]/
      +page.svelte   // /blog/:slug

// Navigation
<a href="/about">About</a>
<a href="/blog/my-post">Blog Post</a>
๐Ÿ“ File-based routing with folders and +page.svelte
๐Ÿ”— Automatic code splitting per route
๐ŸŽฏ Dynamic routes with [param] syntax
โšก Built-in preloading with data attributes

More Svelte tasks

Back to the full SvelteKit cheat sheet