Context
DinoSsr is an experimental work in progress and subject to change!
Routes are rendered with access to a global Svelte context. Context data is also accessible from any child component.
<script>
import {getContext} from 'svelte';
const url = getContext('url');
</script>
<p>The current page is: <code>{url.pathname}</code></p>
Available context properties are:
url
An instance of URL
for the current route.
pattern
The URL Pattern pathname of the current route.
params
An object of any URL Pattern matches.
browser
true
if component is an
Island else undefined
.
publicData
An object for which custom route data is assigned. This data will be available both server-side and client-side.
serverData
Like publicData
but available only server-side.
Context data should be JSON serializable.