Svelte Sapper detecting route change

392 Views Asked by At

I have an app written in svelte with sapper, where I have several routes created in a Next/Sapper way as separate files in routes folder. How can I detect the route change and where, I need to close navigation on mobile after user selects the route, however nothing is logged to the console unless page is refreshed.

<script>
    import CartWidget from '../shared/CartWidget.svelte'
    import { onMount } from 'svelte'

    onMount(() => {
        let path = window.location.pathname
        console.log(path)
    })
    export let segment = '';
</script>

Thanks for advices

0

There are 0 best solutions below