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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@cantoo/navigation

v1.0.3

Published

React Universal Navigation (pure React version)

Readme

React Universal Navigation (React)

Pure React implementation of the universal navigation component.

Install

npm i @cantoo/navigation

Peer dependencies:

{
  "react": ">=16.13.1"
}

Why?

Navigation is often modeled after browser history, but React components should depend only on the props they receive. This component provides a simple, declarative way to navigate between screens in React by switching named children.

Usage

import React from 'react'
import Navigation, { Slide, asSlide } from '@cantoo/navigation'

const Page = ({ name, color, children }) => (
  <div style={{ backgroundColor: color, padding: 20, height: '100%' }}>
    <h2>Page {name}</h2>
    {children}
  </div>
)

const Page2 = asSlide(Page, '2')

export default function App() {
  const [active, setActive] = React.useState('0')
  return (
    <div style={{ height: '100dvh', width: '100dvw' }}>
      <div style={{ display: 'flex', gap: 10 }}>
        {['0', '1', '2'].map(i => (
          <button key={i} onClick={() => setActive(i)}>Navigate to {i}</button>
        ))}
      </div>
      <div style={{ height: '100%', overflow: 'hidden' }}>
        <Navigation active={active} duration={500}>
          <Slide name="0" Component={Page} color="tomato">
            <p>This is page 0 using the pure React implementation</p>
          </Slide>
          <Slide name="1" Component={Page} color="royalblue">
            <p>This is page 1</p>
          </Slide>
          <Page2 name="2" color="seagreen">
            <p>This is page 2 using the asSlide HOC</p>
          </Page2>
        </Navigation>
      </div>
    </div>
  )
}

API

  • Navigation props:

    • active: string – name of the active slide to display
    • duration?: number – transition duration in ms (default: 500)
    • children – only children with a name prop are considered slides
  • Helpers:

    • Slide – wrapper to add a name prop to any component
    • asSlide(Component, defaultName) – HOC version of Slide

TypeScript

When your children components do not declare a name prop, use Slide or asSlide to satisfy typing while keeping the same runtime behavior.

Notes

  • Every child used as a slide must receive a name prop.
  • If active does not match any child, the first child is displayed and a warning is logged.