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

@zmdb/react

v1.0.0-beta.2

Published

React context, query, and mutation lifecycle bindings for generated zmdb clients.

Readme

@zmdb/react

@zmdb/react binds an application-generated zmdb client to one React tree. It provides a typed client context plus query and mutation hooks whose requests follow React effect and unmount lifetimes. The package adds no cache, retry, polling, request encoding, or response handling; those remain application policy and @zmdb/client responsibilities.

Install

yarn add @zmdb/[email protected] react@19

React is a required peer. TypeScript applications also need React's matching declaration package.

Create one typed binding

import { createZmdbReact } from '@zmdb/react';
import type { ApiClient } from './generated/http-client.generated.js';

export const apiReact = createZmdbReact<ApiClient>('AccountApi');

Render the generated client at the application boundary:

import { createElement } from 'react';
import { apiReact } from './api-react.js';
import { api } from './api.js';

createElement(apiReact.ZmdbClientProvider, { client: api }, createElement(App));

Each factory call owns a separate context. A hook outside its matching provider throws an error naming the binding instead of reading a global fallback client.

Query

const user = apiReact.useZmdbQuery((client, signal) => client.getUser({ id: userId }, { signal }), [userId]);

The query starts after React commits the effect. A dependency change clears data for the old identity, aborts its request, and generation-guards late completion. refresh() retains the last successful data while the replacement request is loading. Server rendering runs no effect and therefore starts no request.

Mutation

const rename = apiReact.useZmdbMutation((client, input: { id: string; name: string }, signal) => client.renameUser(input, { signal }));

await rename.mutate({ id: userId, name });

Concurrent mutation promises remain independent. The visible error belongs only to the newest-started mutation, pending remains true until every in-flight call settles, and unmount aborts every active controller without writing state afterwards.

Lifecycle policy

  • StrictMode setup/cleanup replay aborts the replayed request before the replacement remains live.
  • Client errors are stored and rethrown by identity; the hooks do not wrap or normalize them.
  • There is no shared cache, implicit retry, focus refetch, polling, or mutation replay.
  • dependencies follows the same stable-length and exhaustive-value rules as React's built-in dependency lists.

The provider also exposes a low-level per-tree request-lifecycle seam for official environment adapters. Most applications should not set it directly; @zmdb/react-native uses it to apply AppState policy to the actual controllers owned by these hooks without copying their state implementation.

Full project documentation is at https://ambasta.github.io/zmdb/.

License

GNU General Public License v3.0 or later (GPL-3.0-or-later).