1.3.0 • Published 3 years ago
route-link v1.3.0
Install
npm i route-link
Example Usage
import { route, extend } from "route-link";
const posts = route("/posts");
const post = extend(posts, '/:post_id')
// generate type safe links
posts.link() // /posts
post.link({ post_id: "1" }); // /posts/1
// match URLs to path
post.match(post.link({ post_id: "1" })) // { post_id: "1" };
post.match("/foo")) // false
// use route path
<Route path={post.path}/>
as a convivnce, link
and match
are also exported separately