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

@hizzlewp/history

v1.3.5

Published

History utilities for WordPress plugins

Readme

History

This package contains history utilities for the HizzleWP framework.

Usage example:

import { Router, Outlet, updatePath, useQuery, onQueryChange, useRoute } from '@hizzlewp/history';
import { Button } from '@wordpress/components';

/**
 * Display the home page.
 */
const Home = () => <div>Home Page</div>;

/**
 * Display the user's page layoute.
 */
const UserLayout = () => (
    <div>
        <h1>User's Page</h1>
        <Outlet path="/users" />
    </div>
);

/**
 * Display the user list.
 */
const UserList = () => {
    // Get the query parameters.
    const {page} = useQuery();

    // Get the users. You can use any data source you want.
    const users = useUsers({page });

    // Move to the next page.
    const onChangePage = onQueryChange('page');

    return (
        <div>
            <div>User List</div>
            {users.map((user) => (
                <Button key={user.id} onClick={() => updatePath(`/users/${user.id}`)}>
                    {user.name}
                </Button>
            ))}
            <Button onClick={() => onChangePage(page + 1)}>Next Page</Button>
        </div>
    );
};

/**
 * Display a user's detail.
 */
const UserDetail = () => {
    const { params } = useRoute();
    return <div>User Detail {params.get('id')}</div>;
};

// Define routes
const routes = [
  {
    path: '/',
    element: <Home />,
  },
  {
    path: '/users',
    element: <UserLayout />,
    children: [
      {
        path: '/users/:id',
        element: <UserDetail />,
      }
    ],
    index: <UserList />,
  },
];

// Use in app
const App = () => (
  <Router routes={routes}>
    <nav>
      <Button onClick={() => updatePath('/')}>Home</Button>
      <Button onClick={() => updatePath('/users')}>Users</Button>
    </nav>
    <Outlet />
  </Router>
);

addHistoryListener

Adds a listener that runs on history change.

Parameters

  • listener Function: Listener to run on history change.

Returns

  • Function: Function to remove listeners.

getHistory

Recreate history to coerce React Router into accepting path arguments found in query parameter hizzlewp_path, allowing a url hash to be avoided. Since hash portions of the url are not sent server side, full route information can be detected by the server.

Returns

  • History: React-router history object with get location modified.

getNewPath

Return a URL with set query parameters.

Parameters

  • query Object: object of params to be updated.
  • path string: Relative path (defaults to current path).

Returns

  • string: Updated URL merging query params into existing params.

getPath

Get the current path from history.

Returns

  • string: Current path.

getQuery

Get the current query string, parsed into an object, from history.

Returns

  • Record<string, QueryArgParsed>: Current query object, defaults to empty object.

goToParent

Navigates to the parent path.

navigateTo

A utility function that navigates to a page.

Parameters

  • args Object: - All arguments.
  • args.url string: - Relative path or absolute url to navigate to

onQueryChange

This function returns an event handler for the given param

Parameters

  • param string: The parameter in the querystring which should be updated (ex paged, per_page)
  • path string: Relative path (defaults to current path).
  • query string: object of current query params (defaults to current querystring).

Returns

  • Function: A callback which will update param to the passed value when called.

Outlet

Outlet component for rendering nested routes in the router.

This component is responsible for rendering the appropriate route element based on the current routing context. It handles nested routing by finding and rendering the next appropriate outlet or index route.

Usage

// Render the first outlet
<Outlet />

// Render a specific outlet by path
<Outlet path="/dashboard" />

Parameters

  • props - The component props
  • props.path - Don't provide for the first . Always provide for other paths otherwise your browser will hang.

Router

Router component

Type

  • React.FC< RouterProps >

updatePath

Updates the path of the current page.

Parameters

  • path string: Relative path (defaults to current path).

updateQueryString

Updates the query parameters of the current page.

Parameters

  • query Object: object of params to be updated.
  • path string: Relative path (defaults to current path).
  • currentQuery Object: object of current query params (defaults to current querystring).

usePath

A hook that returns the current path.

Returns

  • string: The current path.

useQuery

Like getQuery but in useHook format for easy usage in React functional components

Returns

  • Record<string, string>: Current query object, defaults to empty object.

useRoute

Undocumented declaration.