preact-router-minimal
v0.1.10
Published
> This was a fun little project to tinker with but I have no plans to maintain it. Please user [preact-router](https://github.com/developit/preact-router) instead.
Readme
Deprecated.
This was a fun little project to tinker with but I have no plans to maintain it. Please user preact-router instead.
What?
A tiny ~650b router modeled after (and just over 1/3 the size of) preact-router.
Why?
I'm obsessive about download size. While preact-router is amazing, it does more than I, and likely many others, need.
If all you want is declarative routing for preact with few bells and whistles, this is your stop.
Differences to preact-router
- You may only use one instance of
preact-router-minimalon a given page. pathonly handles exact matches and colon wildcards such as/entries/:id/comments.Match,Link, andRedirectare not implemented. (As a note,preact-routeris ~1.8k withoutMatchandLink.)- Custom History is not supported.
Other than that, use preact-router-minimal like you would preact-router.
Similarities to preact-router
- Exports
Routerandroute - Supports
nativelinks - Identical markup layout
Usage Example
import { h, Component } from 'preact';
import { Router, route } from 'preact-router-minimal';
export default class App extends Component {
render(props, state) {
return (
<Router onChange={onChange}>
<Login path="/" />
<Posts path="/posts" />
<Post path="/post/:id" />
</Router>
);
}
}
