When navigating back (either via swipe back on iOS or physical back button on Android), the router history gets corrupted — instead of removing the current page from history, it adds it again.
History at /page4/: ["/", "/page1/", "/page2/", "/page3/"]
Press back → navigates to /page3/ ✓
History after back: ["/", "/page1/", "/page2/", "/page3/", "/page4/"] ← /page4/ added instead of removed!
Press back again → navigates to wrong page, DOM breaks, links become unclickable
I confirmed this with f7.on('routeChange', ...) event listener logging both newRoute.url and router.history.
What I’ve tried
preloadPreviousPage: false → fixes history corruption but back navigation shows blank page (previous page not rendered)
uniqueHistory: true + allowDuplicateUrls: false → doesn’t fix the issue
browserHistoryInitialMatch: true → no effect
browserHistorySeparator: '' → no effect
Manually deleting from history array → unstable behavior
Disabling browserHistory and pushState → fixes corruption but loses browser history functionality
Current workaround
On Android: intercept the back button, show “Press again to exit” toast on second press, exit app on third. This masks the problem but doesn’t fix it.
On iOS: disabled swipe back (mdSwipeBack: false) to avoid the issue entirely.
Question
Is this a known bug with browserHistory: true + pushState: true in Capacitor environment? Is there a recommended way to use back navigation without history corruption?
I found a fix for this. The problem is in framework7-svelte (shared/components-router.js, pageComponentLoader), not in the F7 router itself.
Cause (my best guess from a DOM trace): with preloadPreviousPage, F7 moves the preloaded previous page before the current page with insertBefore (back.js), but pageComponentLoader pushes it at the end of viewRouter.pages. With Svelte 5 keyed {#each}, removing a block removes its whole DOM range, so the page F7 moved into that range is removed together with the old page. On the next back, the following preloaded page becomes .page-current, so one page gets skipped.
Fix: in pageComponentLoader:
Keep a copy of the current children before changing pages, and for preload (backward) loads insert the new page before the current page instead of pushing it at the end: