I'm using Svelte and Sapper for a web app where I need to proceed to the next page dynamically, i.e. after something happens (a Web Bluetooth connection) - not just from an <a>
element click.
For <a>
links, Sapper intercepts these and performs client-side routing. How can I achieve client-side routing myself, via JavaScript?
If, for example, I call location.href = ...
then this is not intercepted and it involves a roundtrip to the server for the next page.
Is there a neat way of doing this? (Something like router.route('/my-page')
)?
For Svelte-3:
import { goto } from '@sapper/app'
goto('/profiles')
I found it here in the docs:
import { goto } from 'sapper/runtime.js';
goto('/my-page');
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