I am new to svelte. I have a route defined like this: /posts/[slug]
. How do I access the slug
in page.svelte
file?
<script>
let slug = ...
</script>
I have tried searching online but cannot find the solution.
I am new to svelte. I have a route defined like this: /posts/[slug]
. How do I access the slug
in page.svelte
file?
<script>
let slug = ...
</script>
I have tried searching online but cannot find the solution.
You would use the page store, which you can use from wherever in your app (pages or components)
import { page } from '$app/stores';
let slug = $page.params.slug;
© 2022 - 2024 — McMap. All rights reserved.