Missing navigation history/back functionality
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.9k
- Forks
- 190
- Avg merge
- 12h 50m
- Merged PRs (30d)
- 3
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start by reviewing wouter's existing router and navigation entry points, then compare them with the proposed useHistory and navigateBack API. Done means the project has a decided scope and documented behavior for previous-route navigation, fallback handling, and history state management.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100