Test: Redirect on Back

Current Page: redirect

⚠️ NOT RECOMMENDED - Known Limitations

Using router.push() inside a handler is not supported and causes unpredictable behavior.

  • After page refresh, browser back button may not work as expected
  • router.back() API may work while browser back button fails
  • Navigation may jump to unexpected pages due to session token mismatch

Test Steps to Reproduce Issue:

  1. Press browser back → Redirects to /nohandler ✓
  2. Press browser back → Returns to this page ✓
  3. Refresh this page
  4. Press browser back → Redirects to /nohandler ✓
  5. Press browser back → Goes to Home instead of this page ✗

✅ Use Safe Redirect Pattern Instead:

If you need to redirect on back, use a modal and let the user trigger navigation:

// ✅ SAFE: Open modal, user triggers navigation
useRegisterBackNavigationHandler(() => {
  overlay.open(({ isOpen, close }) => (
    <Modal onConfirm={() => router.push('/page')} />
  ));
  return false; // Return immediately
});

→ See Safe Redirect Pattern Example

Back to Home

See Limitations documentation for more details.