Skip to content

Type Alias: ShallowNavigation

API / @xmachines/play-sveltekit-router / ShallowNavigation

type ShallowNavigation = "ignore" | "sync";

Defined in: play-sveltekit-router/src/sveltekit-router-bridge.ts:38

What the bridge does with a shallow navigation of SvelteKit: goto(url, { shallow: true }), pushState, replaceState, and a back or forward step between shallow entries.

  • "ignore" — the machine keeps its route. The bridge watches afterNavigate.
  • "sync" — the machine follows the URL that the browser shows, the shallow URL too. The bridge watches page of $app/state. Give each shallow URL a route in the machine: for a URL that the machine does not know, the bridge navigates back to the route of the machine, and that navigation loads the page. On SvelteKit 2, give pushState and replaceState a new state object on each call: SvelteKit 2 changes only page.state for a shallow navigation, so a call with the state object of the page changes nothing that the bridge can observe.