Back button exits app instead of navigating back — Vue + Capacitor + Vite #8014
Unanswered
JonathasSC
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm having trouble handling navigation between screens and managing the hardware back button with Capacitor, Vue 3, and Vue Router 4.
The issue I'm facing:
<router-link>
orrouter.push()
within the app.Implementation:
useBackButton.js
:BackButton.vue
:I included this composable in my App.vue component.
I've already run
npx cap sync
andnpx cap copy
, but the issue persists:The back button closes the app instead of navigating to the previous route.
My questions:
router.back()
the right approach here, or should I use a different method?removeAllListeners()
too aggressive? Should I use a more selective cleanup for this event?AndroidManifest.xml
or Capacitor's config to override the default back button behavior?My environment:
Any help would be really appreciated!
Thanks a lot in advance! 🙏
Beta Was this translation helpful? Give feedback.
All reactions