diff --git a/src/index.tsx b/src/index.tsx index e11485ba..2665c903 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -5,6 +5,7 @@ import { HashRouter as Router } from 'react-router-dom'; import './lib/init-translations'; import './index.css'; import './themes.css'; +import { App as CapacitorApp } from '@capacitor/app'; const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement); root.render( @@ -14,3 +15,12 @@ root.render( , ); + +// add back button in android app +CapacitorApp.addListener('backButton', ({ canGoBack }) => { + if (canGoBack) { + window.history.back(); + } else { + CapacitorApp.exitApp(); + } +});