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

@karpo.dev/sdk-react

v0.4.0

Published

React bindings for the Karpo client — useQuery, useMutation, useSyncStatus.

Readme

@karpo.dev/sdk-react

React bindings for the Karpo client. A query re-runs after any write touching its tables, so there is no refetch to call and no cache to invalidate.

npm install @karpo.dev/sdk-react

Peer dependency: React ≥ 18. Pair it with @karpo.dev/sdk-web in a browser app.

Usage

Wire the client once, at the entry point. The provider is only a loading gate — remove it and the hooks still work.

import { KarpoProvider } from "@karpo.dev/sdk-react";
import { initKarpo, karpo } from "../karpo/generated/karpo.js";

void initKarpo({ user: "u01", target: "dev" });

createRoot(document.getElementById("root")!).render(
  <KarpoProvider karpo={karpo} fallback={<p>Opening the local database…</p>}>
    <App />
  </KarpoProvider>,
);

Then read and write from components:

import { useMutation, useQuery } from "@karpo.dev/sdk-react";
import { db } from "../karpo/generated/karpo.js";

export function Todos({ workspaceId }: { workspaceId: string }) {
  const { data: todos = [], isLoading, error } = useQuery(
    db.workspaces.todos.where({ containerId: workspaceId }).orderBy("title"),
  );

  // Lands in local SQLite first and syncs in the background: resolves offline.
  const [addTodo, adding] = useMutation(async (title: string) =>
    db.workspaces.todos.insert({ containerId: workspaceId, title }),
  );

  if (error) return <p role="alert">Could not read todos: {String(error)}</p>;
  if (isLoading) return <p>Loading…</p>;
  return (
    <ul>
      {todos.map((t) => <li key={t.id}>{t.title}</li>)}
      <button disabled={adding.pending} onClick={() => void addTodo("New")}>Add</button>
    </ul>
  );
}

Handling error is not optional: a failed query leaves isLoading false and data undefined. Three more hooks take the same karpo handle — useSyncStatus, useAuthSession and useCurrentUser.

For state that must survive a reload and must never reach the server — a draft, a preference, a dismissed banner — usePersistentState is useState with a device-local store behind it:

const [draft, setDraft] = usePersistentState("compose-draft", "");

Once karpo.ready has resolved it returns the persisted value on its first render, so there is no isLoading and no flash of the initial value over an existing draft. The setter re-renders synchronously and persists in the background. It shares one namespace with kv from the generated karpo.ts: the same key names the same value. Schema tables synchronize; this does not.

Docs: https://karpo.dev/react. Source: https://github.com/Chirich-GmbH/karpo-core