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

kiss-router-react

v2.1.0

Published

React components to use with kiss-router

Readme

KISS Router React.js Binding

This is a binding to use kiss-router comfortably within React.js. It's a collection of components to display components based upon the current route, and to navigate.

In addition to simple routing, kiss-router-react also supports triggering a function to produce a promise on matching a route. If you specify a resolvePromise function in your route definition, and use the <AsyncRouter /> component, instead of passing just the url and query parameters to your render callback or component, it will pass params, loading, data and error.

Here's an example of it in use:

import createBrowserHistory from 'history/createBrowserHistory';
import { Router } from 'kiss-router';
import React, { Component, PropTypes } from 'react';
import { AsyncRouter, Route, NotFound, Link } from 'kiss-router-react';

const routes = [
  { name: 'HOME', path: '/' },
  { name: 'POSTS', path: '/posts', resolvePromise: ({ page = 1 }) => /* return a promise*/ },
  { name: 'POST', path: '/posts/:id', resolvePromise: ({ id }) => /* return a promise*/ },
];

function Home(props) {
  return (<h1>Homepage</h1>);
}

function Posts({ params, waiting, error, data }) {
  if (waiting) return <h1>Loading Posts</h1>;
  if (error) return <h1>Error Loading Posts: {error}</h1>;
  
  // `data` is the resolved promise data 
  const posts = data.map(post =>
    (<Link to={`/posts/${post.id}`}>Post {post.id}</Link>)
  );

  return (
    <div>
      <h1>Posts</h1>
      <h2>Page {params.page || 1}</h2>
      <div>{posts}</div>
    </div>
  );
}

function Post({ waiting, error, data }) {
  if (waiting) return <h1>Loading Posts</h1>;
  if (error) return <h1>Error Loading Posts: {error}</h1>;

  return (<h1>Post {data.id}</h1>);
};

function NotFound() {
  return (<h1>Page Not Found!</h1>);
}

class MyApp extends Component {
  constructor(props) {
    super(props);

    const history = createBrowserHistory();
    const router = new Router(routes, history);
    this.state = { router };
  }

  render() {
    return (
      <AsyncRouter router={this.state.router}>
        <h1>
          <Link to="/">My App</Link>
        </h1>
        
        <Route matching="HOME" component={Home} />
        <Route matching="POSTS" component={Posts} />
        <Route matching="POST" component={Post} />

        <NotFound component={NotFound} />
      </Router>
    );
  }
}

The components exposed by this library are as follows:

<Router>

This component provides the context to all of the other components so you aren't required to pass down a bunch of properties for the routes.

Properties

| Property | Description | | --- | --- | | currentRoute | The currently matched route. Should be provided by a matcher from kiss-router | | history | A history object with push and replace for the <Link> component to use. |

<AsyncRouter>

This is an uncontrolled version of the <Router /> component with support for resolving promises on navigation to a route. In your routes array, you can include a function called resolvePromise with a route, that takes an object (containing url and query params), and returns a promise.

Properties

| Property | Description | | --- | --- | | router | An instance of Router from kiss-router |

<Route>

Allows you to display content when a route match occurs. Takes a component to display the route. It will render the component with params (an object with url & query params), waiting (if waiting on promise to resolve), data (data from resolved promise) and error (error from rejected promise). If your route does not use resolvePromise, you can ignore the waiting, data, and error keys.

Properties

| Property | Description | | --- | --- | | matching | The route name to match on | | component | A component to render when matching. Will be passed params, waiting, data and error |

<NotFound>

Allows you to display content when no route is matched.

Properties

| Property | Description | | --- | --- | | component | A component to render when no match occurs. No props will be passed to it |

<Link>

Produces a link that will use push or replace from the history object provided to <Router>. This needs to be used for internal links to prevent page refreshes.

| Property | Description | | --- | --- | | to | The pathname to navigate to | | replace | If true, replace instead of pushing history |