Skip to main content
Basic Svelte
Introduction
Reactivity
Props
Logic
Events
Bindings
Classes and styles
Actions
Transitions
Advanced Svelte
Advanced reactivity
Reusing content
Motion
Advanced bindings
Advanced transitions
Context API
Special elements
<script module>
Next steps
Basic SvelteKit
Introduction
Routing
Loading data
Headers and cookies
Shared modules
Forms
API routes
$app/state
Errors and redirects
Advanced SvelteKit
Hooks
Page options
Link options
Advanced routing
Advanced loading
Environment variables
Conclusion

To create routes with dynamic parameters, use square brackets around a valid variable name. For example, a file like src/routes/blog/[slug]/+page.svelte will create a route that matches /blog/one, /blog/two, /blog/three and so on.

Let’s create that file:

src/routes/blog/[slug]/+page
<h1>blog post</h1>

We can now navigate from the /blog page to individual blog posts. In the next chapter, we’ll see how to load their content.

Multiple route parameters can appear within one URL segment, as long as they are separated by at least one static character: foo/[bar]x[baz] is a valid route where [bar] and [baz] are dynamic parameters.

Edit this page on GitHub

previous next
1
2
<p>home</p>