Svelte Craft Design System

Svelte Craft is a lightweight, flexible design system for building responsive layouts in Svelte and handling prose.

npx jsrepo add --repo github/sikandarjodd/craft

HTML Attribute

markdown

Learn SvelteKit Routing with Various Examples

SvelteKit, the official framework for building Svelte applications, offers a powerful and intuitive routing system. In this comprehensive guide, we'll explore SvelteKit routing with detailed examples to help you master navigation in your SvelteKit projects.

Basic File-based Routing

SvelteKit uses a file-based routing system where the structure of your src/routes directory defines your application's routes.

Basic Routes

src/routes/
└── +page.svelte

Nested Routes

src/routes/
├── dashboard/
│   ├── +page.svelte
│   └── +page.server.ts
└── +page.svelte

Dynamic Routes

src/routes/
├── blog/
│   ├── [slug]/
│   │   ├── +page.js
│   │   └── +page.svelte
│   ├── category/
│   │   └── [[tag]]/
│   │       └── +page.svelte
│   └── +page.svelte
└── +page.svelte

Key takeaways:

  • Use file structure for routes
  • [param] for dynamic segments
  • [[param]] for optional parameters
  • [...param] for rest parameters
  • +page.js for data loading
  • +page.server.ts for loading server-side data
  • src/routes/index.svelte for the root route