In Sapper, AFAIK from documentation. The only way to access URL params are through preload()
function, from which params are available inside params
object.
The thing is that I want to access these params ouside of preload()
function. From an eagle eye view of documentation. I don't / can't see the solution to my problem / requirement.
I have tried setting a property for url param inside data()
. But it seems preload()
has no access to data
whether getting wise or setting wise. It is not meant for those things.
<script>
import { stores } from "@sapper/app";
const { page } = stores();
const { slug } = $page.params;
</script>
https://sapper.svelte.dev/docs/#Stores
If you are using v3 Svelte and latest alpha of Sapper, import page which is now provided as a store.
import { page } from '@sapper/app';
const {slug} = $page.params;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With