URL parameters

Routify can access URL parameters by using parameterized files and folders.

A file or folder is parameterized if it is wrapped in brackets. (ie. [slug].svelte or [slug]/index.svelte)


Local parameters

A parameterized file/folder can access its parameter with

export let slug

A Folder's parameter is passed to [slug]/_layout.svelte


Global parameters

To access all parameters, including query parameters, from any component use the $params helper. The `$params` helper can be called from a page, layout, or component nested within the page without having to pass the property down.

import { params } from '@roxi/routify' $: slug = $params.slug
import { params } from '@roxi/routify'
$: slug = $params.slug

Synchronicity

Local parameters are directly synchronized with the address bar whereas global parameters are first propagated through the layout component chain. The propagation is to prevent race conditions between parameters and component state.


Writing good documentation that is up-to-date is difficult. If you notice a mistake, help us out.