-
-
Notifications
You must be signed in to change notification settings - Fork 175
Open
Description
Problem
Currently, wouter doesn't provide a built-in way to navigate back to the previous page or access navigation history. This forces developers to implement workarounds like:
- Using
window.history.back()directly (which may cause page reloads) - Implementing custom state management with sessionStorage/localStorage
- Creating complex navigation state tracking systems
Use Case
In a typical SPA, users expect the back button to work intuitively:
- From a product page back to the store page
- From an order details page back to the orders list
- From any nested page back to its parent
Proposed Solution
It would be great if wouter could provide:
- A
useHistoryhook that gives access to navigation history - A
navigateBack()function that safely goes to the previous route - History state management that works seamlessly with the router
Current Workaround
const handleBack = useCallback(() => {
if (window.history.length > 1) {
window.history.back();
} else {
navigate('/fallback-route');
}
}, [navigate]);Questions
- Is there a recommended way to handle back navigation in wouter?
- Are there plans to add history management features?
- Should we consider using a different router that has this functionality built-in?
This would significantly improve the developer experience and make wouter more competitive with other routing solutions.
KutnerUri, AbdouTanta, danielyogel, ovinix, antoniave and 1 moredanielyogel
Metadata
Metadata
Assignees
Labels
No labels