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

standard-navigation

v0.0.7

Published

Standard navigation API for navigation libraries

Downloads

1,329,220

Readme

Standard Navigation

A standard API for creating navigators that can work with multiple navigation libraries, such as React Navigation and Expo Router.

This package only contains minimal helpers and types. The actual implementation of integrating with this API should live in respective libraries (e.g. React Navigation, Expo Router, etc.).

API

import * as React from 'react';
import { createStandardNavigator } from 'standard-navigation';

type MyNavigatorOptions = {
  title?: string;
};

type MyNavigatorEventMap = {
  tabPress: {
    data: { isAlreadyFocused: boolean };
    canPreventDefault: true;
  };
};

type MyNavigatorProps = {
  className?: string;
};

const MyStandardNavigator = createStandardNavigator<
  MyNavigatorOptions,
  MyNavigatorEventMap,
  MyNavigatorProps
>(({ state, descriptors, actions, emitter, className }) => {
  return (
    <div className={className}>
      {state.routes.map((route, index) => (
        <React.Activity
          key={route.key}
          mode={state.index === index ? 'visible' : 'hidden'}
        >
          {descriptors[route.key].render()}
        </React.Activity>
      ))}
      {state.routes.map((route, index) => (
        <a
          href={route.href}
          key={route.key}
          onClick={(e) => {
            e.preventDefault();

            const event = emitter.emit({
              type: 'tabPress',
              target: route.key,
              canPreventDefault: true,
              data: {
                isAlreadyFocused: state.index === index,
              },
            });

            if (event.defaultPrevented) {
              return;
            }

            actions.navigate(route.name, route.params);
          }}
        >
          {descriptors[route.key].options.title}
        </a>
      ))}
    </div>
  );
});

A navigator is created by calling createStandardNavigator with a function. It can be typed with three generics:

  • NavigatorOptions: The options for each route descriptor.
  • NavigatorEventMap: The events that can be emitted by the navigator.
  • NavigatorProps: Additional props accepted by the navigator content.

It returns an object as follows:

{
  type: 'standard',
  version: 1,
  NavigatorContent: React.ComponentType,
}

This object can be used by helpers exported from libraries like React Navigation and Expo Router to create navigators to use in those libraries. Refer to the documentation of those libraries for more details on how to use this API with them.

The callback function receives an object with the following properties:

state

The current navigation state:

  • index: The index of the currently focused route in routes.
  • routes: An array of route objects, each containing the following properties:
    • key: A unique key for the route.
    • name: The name of the route.
    • params: An optional object of params for the route.
    • href: An href for the route, used for web navigation, or undefined if unavailable.

descriptors

An object mapping each route's key to a descriptor for that route:

  • options: The options for the route, e.g. title.
  • render: A function that returns the React element to render for the route.

actions

An object of navigation actions that the navigator can perform:

  • navigate: Navigates to a route. Accepts name and params to navigate by route name and params.
  • back: Goes back to the previous route in history.

emitter

An event emitter that can be used to emit events. Calling emit accepts an object with the following properties:

  • type: The type of the event (e.g. tabPress).
  • target: An optional key of the route which is the target of the event.
  • canPreventDefault: When the event allows preventing the default action, set this to true to enable event.preventDefault() on the returned event.
  • data: Data associated with the event. This is optional when the event's data type includes undefined.

The returned event object contains a defaultPrevented boolean (when canPreventDefault is true) which can be used to check whether event.preventDefault() was called by a listener.