ionic-team / ionic-team/ionic-framework
feat: fallback / catch all route for ion-router
- Dominant language
- TypeScript
- Stars
- 52.7k
- Forks
- 13.3k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 51
Description
### Prerequisites
- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already include this feature request, without success.
### Describe the Feature Request
This is a follow up for #18687.
The only way to do a fallback route as of today is to use `url="/:any"` :
```html
```
This "trick" is not documented.
### Describe the Use Case
Most app need to display a 404 page or redirect the user to a sensible page when the url is not found.
### Describe Preferred Solution
`` would be nice as it would be consistent with with ion-route-redirect [usage of *](https://ionicframework.com/docs/api/route-redirect#usage).
Whatever solution is picked should be documented as it is a common use case.
### Describe Alternatives
There are several solution:
1. Keep the current `` but document it
2. Use `` this would be consistent with ion-route-redirect [usage of *](https://ionicframework.com/docs/api/route-redirect#usage)
3. Use `` (i.e. no url)
### Related Code
_No response_
### Additional Information
I'm up to help implement and/or document this once a solution is picked.
What do you think ?
Bonus question: what should we do when multiple catch all routes are defined ? My preference would be to trigger an error as there should be no reason to be in this situation. Note that as of today the first catch-all route would be used but the current behavior seems brittle as it is mostly an implementation detail and not covered by tests.
Contributor guide
Assessment
This issue has not been assessed yet.