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

@goodnight-dev/react-hooks

v0.3.0

Published

Small, strict, tree-shakeable React hooks — the ones you end up writing in every project, packaged the right way.

Downloads

548

Readme

@goodnight-dev/react-hooks

Small, strict, modern React hooks — the ones you end up writing in every project, packaged the right way.

npm CI docs

Status: bootstrapping — the packaging, CI, docs, and release pipeline are in place; the hook surface is still one hook and growing. As much a showcase of hook-packaging best practices as a hooks library.

Install

pnpm add @goodnight-dev/react-hooks

Requires React >=19.

Two ways to import

// 1. Barrel — everything from one entry point.
import { useLocalStorage, useTheme } from '@goodnight-dev/react-hooks';

// 2. Subpath — smallest possible import, no barrel involved at all.
import { useTheme } from '@goodnight-dev/react-hooks/useTheme';
import { useLocalStorage } from '@goodnight-dev/react-hooks/useLocalStorage';

Both are fully typed, ESM-only, and tree-shakable.

API

| Hook | Description | | ------------------------------- | ---------------------------------------------------------------------------------- | | useTheme() | Reads the OS prefers-color-scheme, live-updating on change. | | useLocalStorage(key, initial) | Reads and writes a JSON-serializable value in localStorage, syncing across tabs. | | useWindowSize() | Reads the viewport width / height, live-updating on resize. |

import { useLocalStorage, useTheme } from '@goodnight-dev/react-hooks';

// Module scope: created once when this file loads, never re-allocated on
// render, so there's nothing to memoize.
const defaultSettings = { seen: false };

function App() {
  const { theme, isDarkMode } = useTheme();
  const [settings, setSettings] = useLocalStorage(
    `users-${userId}`,
    defaultSettings,
  );

  if (theme === undefined) return null; // avoid a flash of the wrong theme
  return (
    <div data-theme={theme}>
      {isDarkMode ? '🌙' : '☀️'}
      <button onClick={() => setSettings((s) => ({ ...s, seen: true }))}>
        Dismiss
      </button>
    </div>
  );
}

See src/use-theme.md, src/use-local-storage.md, and src/use-window-size.md for the design rationale behind each.

Project goals

  • 100% TypeScript with declaration files generated for consumers
  • Modern ESM only, React >=19 peer dependency
  • SSR-safe and concurrent-safe: every hook is built on useSyncExternalStore where it subscribes to something outside React
  • Strictest practical linting + formatting (typescript-eslint strictTypeChecked, eslint-plugin-react-hooks, Prettier)
  • Importable as a whole or by tree-shakable subpath, per hook
  • Comprehensive generated API docs
  • Zero third-party runtime dependencies

Principles

This repo is opinionated about how the code is written. See CONTRIBUTING.md for the full rationale; in short:

  • SSR-safe and concurrent-safe by default. External state (browser APIs, storage, sockets) is read through useSyncExternalStore, never useEffect + useState. A server render never guesses a client-only value.
  • Zero third-party runtime dependencies. Installing this package adds nothing to your node_modules but our own code — React itself is a peer dependency.
  • Per-hook notes. Hooks carry a sibling *.md (repo-only, academic) explaining alternative implementations and why we chose ours — e.g. use-theme.md.

Development

This is a pnpm project. Requires Node >=22.

pnpm install        # install dependencies
pnpm build          # build the package (tsdown)
pnpm test           # run the test suite (vitest)
pnpm typecheck      # tsc --noEmit
pnpm lint           # eslint
pnpm format         # prettier --check
pnpm check          # everything: format, lint, build, typecheck, test, exports
pnpm docs:build     # generate the API docs site (TypeDoc)

Documentation

  • API reference — generated from TSDoc comments.
  • docs/ — recipes (adding a hook, cutting a release) and architecture decision records.

License

MIT © Ian Goodnight