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

@ffdb/react

v0.3.14

Published

React providers and hooks for the FFDB client and offline-sync state

Readme

@ffdb/react

React providers and hooks layered over @ffdb/client and @ffdb/sync-client. The package can be used by React DOM or React Native when the underlying client/session/replica adapters support that runtime.

pnpm add --save-exact @ffdb/[email protected] @ffdb/[email protected] \
  @ffdb/[email protected] react

The matching GitHub Release also provides checksum-listed .tgz files for verified offline installation.

import type { PropsWithChildren } from "react";
import { AuthProvider, FFDBProvider } from "@ffdb/react";

export function Providers({ children }: PropsWithChildren) {
  return (
    <FFDBProvider client={client}>
      <AuthProvider>{children}</AuthProvider>
    </FFDBProvider>
  );
}

Exports include useFFDB, useAuth, useQuery, useSessions, useStorageUpload, useSync, useAutoSync, and optimisticList.

Sync state

function SyncButton() {
  const state = useSync(offlineSyncClient);
  return (
    <button disabled={state.phase !== "idle"} onClick={() => void state.sync()}>
      {state.phase === "idle" ? "Sync" : state.phase}
    </button>
  );
}

useSync uses React's external-store contract to subscribe to an existing OfflineSyncClient. It exposes the current phase, pending count, last-sync time, error, and an explicit sync(signal?) function. It does not construct a replica, start background work, monitor browser focus/AppState/NetInfo, or sync on mount.

For a React DOM application, useAutoSync adds the browser lifecycle:

function ConnectionStatus() {
  const state = useAutoSync(offlineSyncClient);
  return <span>{state.autoSync === "watching" ? "Live" : state.autoSync}</span>;
}

It starts the runtime-neutral controller, pauses while the document is hidden or the browser reports offline, catches up on focus/reconnect, and stops/cleans up listeners on unmount. It is SSR-safe and does not start until the effect mounts. Use useAutoSync(client, { enabled: false }) to retain a manual-only lifecycle. React Native applications should call startAutoSync() directly and forward AppState and, when available, network status to the returned controller.

On the web, provide a browser-compatible FFDBClient and a persistent ReplicaAdapter if reload durability is required. On React Native, use secure credential storage and a verified native adapter such as NativeSQLiteReplica from @ffdb/react-native. In Node-based React rendering, do not start a sync run during server rendering; create runtime-specific clients and adapters outside the render path.

The query and storage hooks call the remote FFDB API. They are not local-replica queries and do not become offline automatically merely because useSync is also present in the component tree.