This repo shows how to implement Ionic Nav in SvelteKit.
Implementing Ionic Nav requires a bit of deviation from the the Ionic API docs. Not too much, but just a bit.
Want to dive into an example? Use the link below to the code-sandbox. After opening the link, please pop-up the render window to see the results.
https://stackblitz.com/github/Tommertom/ionic-svelte-nav-howto
So, you can also clone this repo:
npx degit https://github.com/Tommertom/ionic-svelte-nav-howto ionic-nav
Best is just to look at the sample code in route /nav
- The IonNav component is configured in the
+page.svelte - That page imports from
$libthe NavHome which does the pushing of content (overview->detail) - The
NavHomepushes child/detail views with the props using thenavControllerpushmethod. It can simply import the component and pass it to thepushmethod - If need be, you can add
propsto it, which gets passed to the component - The child/detail page can implement a
ion-backbuttonfor popping the view using the default animation - For now, you have to make sure the
ion-backbuttonhas adefault-href, otherwise it won't show
See code in +page.svelte. For the rest, navController has the same methods as ion-nav - https://ionicframework.com/docs/api/nav
Create component for <ion-nav-link>