Skip to content

Commit 8e3586b

Browse files
docs: document typed params in page props (#15284)
* docs: document typed params in page props * Apply suggestions from code review * Apply suggestion from @dummdidumm * Apply suggestion from @dummdidumm --------- Co-authored-by: Simon H <[email protected]>
1 parent e83246e commit 8e3586b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

documentation/docs/20-core-concepts/10-routing.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ A `+page.svelte` component defines a page of your app. By default, pages are ren
3939

4040
> [!NOTE] SvelteKit uses `<a>` elements to navigate between routes, rather than a framework-specific `<Link>` component.
4141
42-
Pages can receive data from `load` functions via the `data` prop.
42+
Pages can receive data from `load` functions via the `data` prop. They also receive `params`, which is typed based on the route parameters.
4343

4444
```svelte
4545
<!--- file: src/routes/blog/[slug]/+page.svelte --->
4646
<script>
4747
/** @type {import('./$types').PageProps} */
48-
let { data } = $props();
48+
let { data, params } = $props();
4949
</script>
5050
51+
<span>blog/{params.slug}</span>
52+
5153
<h1>{data.title}</h1>
5254
<div>{@html data.content}</div>
5355
```

0 commit comments

Comments
 (0)