Routing Middleware
- Dominant language
- TypeScript
- Stars
- 623
- Forks
- 78
- PR merge metrics
- No merged PRs in 30d
Description
**Enhancement**
A routing middleware that can be used to:
* conditionally render content based on the an outlet
* create links
* determine whether an outlet is active
* provide path and query params.
Possible example usage for routing middleware:
```tsx
const factory = create({ routing });
const MyWidget = factory(function MyWidget({ middleware: { routing } }) {
let node: any = undefined;
if (routing.isExact("home")) {
return
}
if (routing.isMatch("details")) {
const { params, queryParams } = routing.getParams("details");
return (
{JSON.stringify(queryParams)}
{JSON.stringify(params)}
);
}
if (routing.isMatch("about")) {
return
}
return null;
});
```
The middleware could be a factory to that accepts routing configuration to be registered, falling back to using a router defined as an injector, this would provide backwards compatibility with applications that are using class-based widgets.
Additional consideration(s):
* [ ] Support for route based code splitting
Contributor guide
Assessment
This issue has not been assessed yet.