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.
Downloads
9
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-minimal
on a given page. path
only handles exact matches and colon wildcards such as/entries/:id/comments
.Match
,Link
, andRedirect
are not implemented. (As a note,preact-router
is ~1.8k withoutMatch
andLink
.)- Custom History is not supported.
Other than that, use preact-router-minimal
like you would preact-router
.
Similarities to preact-router
- Exports
Router
androute
- Supports
native
links - 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>
);
}
}