you can't intercept the back button. js prevents that.
what you could do is store the 'step' on the session, and on login route, check for that, return step. and pick up from current step. eh? do that on the mounted event.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I would like to redirect users if they hit the browser back button, once they are logged in. So, for example if the user logs in, and then immediately tries to go back with the back button, the user is currently being routed again to the login component. Instead of that, I would like to redirect user to the page he is normally redirect when he logs in. I have done the redirect for routing, but not sure how can I do that for the browser back button:
router.beforeEach((to, from, next) => {
const authenticated = store.getters['auth/getAuthenticated'];
if (to.path == '/login' && authenticated) {
next('intranet');
}
if (to.matched.some(record => record.meta.requiresAuth)) {
// this route requires auth, check if logged in
// if not, redirect to login page.
if (!authenticated) {
next({
path: '/login',
query: { redirect: to.fullPath }
})
} else {
next()
}
} else {
next()
}
})
How can I do that, for the case when the user hits back button?
Please or to participate in this conversation.