v3.2.0 GitHub

Programmatic navigation

If you have access to route object in your component, you can use its push method to navigate to another page.

Important: in version 2.0.0 only string literal is supported

// SomeComponent.svelte
<script>
    import { router } from './router.js';
    router.push('/home');
</script>