npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@linears/react-router

v1.2.1

Published

Small yet effective React router

Downloads

2

Readme

Linears React Router

A small yet effective React router.

Getting Started

Install

You can install the package using:

npm i @linears/react-router

# Or using yarn

yarn add @linears/react-router

Router Component

Router takes the routes infomration in routes prop. Every route is required to have a path and component. The path is the url where the component is rendered. The component should be a reference and shouldn't be called.

import { Router } from "@linears/react-router";
import About from "./routes/about";
import Home from "./routes/home";

const App = () => (
    <Router
        routes={[
            {
                path: "/",
                component: Home,
            },
            {
                path: "/about",
                component: About,
            },
        ]}
        fallback={<div>404 - page not found</div>}
    />
);

Link Component

The Link takes the path in to prop and whenever it is clicked, it will navigate to the path without refreshing the page.

import { Link } from "@linears/react-router";

const MyLink = () => <Link to="/path/to/other/router">About</Link>;

useRouter hook

The useRouter allows you to change the route.

import { useRouter } from "@linears/react-router";

const Component = () => {
    const router = useRouter();
    return <button onClick={() => router.push("/path/to/somewhere")} />;
};

Use cases

Rendering pages conditionally

To render page conditionally you need add a condition property to a route. If condition is met, the component is rendered.

If you set loading property to true, the loadingComponent component will be rendered as long as it is true.

Finally if both loading and condition is falsy the component will redirect to redirectPath;

import { Router } from "@linears/react-router";
import Profile from "./routes/Profile";

const App = () => (
    <Router
        routes={[
            /* ... */
            {
                path: "/profile",
                component: Profile,
                condition: false,
                loading: false,
                loadingComponent: <div>Loading</div>,
                redirectPath: "/about",
            },
        ]}
        fallback={<div>404 - page not found</div>}
    />
);

The example aboce will redirect to /about, because the route condition has not been met and it is not loading.

Rendering dynamic routes

If you add : at a begnning of an "endpoint", it will be considered dynamic and will match any value.

Both the endpoint and the value will be passed to component's props as params. Take look at the example:

import { Router } from "@linears/react-router";

const App = () => (
    <Router
        routes={[
            /* ... */
            {
                path: "/posts/:userId/:postId", // Will match e.g. /posts/abc/xyz
                component: Profile,
            },
        ]}
        fallback={<div>404 - page not found</div>}
    />
);

const Profile = ({ params }) => {
    const postId = params["postId"];

    return; // render something
};