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

@accordsync/react

v0.3.2

Published

React hooks for Accord: records, conflicts and sync status that re-render when local state changes

Readme

@accordsync/react

React hooks for Accord: records, conflicts and sync status that re-render when local state changes, whether from a local write or from sync.

safe-install add @accordsync/react @accordsync/client

or npm install @accordsync/react @accordsync/client. safe-install installs with every install script off and asks before running any.

import { AccordProvider, useConflicts, useRecord, useSyncStatus } from '@accordsync/react';

<AccordProvider client={accord}>
  <App />
</AccordProvider>;

function Dossier({ id }: { id: string }) {
  const d = useRecord(id); // { client_name, visits, documents, status } or undefined
  const { pending, lastError } = useSyncStatus();
  const conflicts = useConflicts(); // conflict() fields waiting for a decision
  // …
}

| Hook | Returns | | ------------------- | -------------------------------------------------------------------------- | | useAccord() | the AccordClient, to write (assign, inc, add, remove, resolve) | | useRecord(id) | the record's fields, or undefined | | useRecords(type?) | ids of the records this device holds | | useConflicts() | every conflicted field with all its values | | useSyncStatus() | { pending, cursor, lastSyncAt, lastError } |

A component re-renders only when what it reads changed. Licence: Apache-2.0.

Prompt for an AI coding agent

Copy this into your coding agent (Claude Code, Cursor, Copilot) to add Accord to an existing app.

Integrate Accord (@accordsync/react 0.3.x) into this React app.
Install: safe-install add @accordsync/react@^0.3.2 @accordsync/client@^0.3.2
Install with safe-install (https://safe-install.benhattab.pro/llms.txt), never npm/pnpm/yarn
directly. Never approve install scripts yourself (no safe-install approve, --force, --yes or
allowScripts edits): if a script is skipped, stop and tell me the package and its scripts.
Create:
1. src/schema.ts exporting the same defineSchema(...) as the Accord server (share the file or
   keep it identical). Import defineSchema, lww, counter, set, conflict from '@accordsync/client'.
2. Open one client at startup: AccordClient.open({ schema, storage: new IndexedDbStorage('<app>'),
   transport: httpTransport({ url: <sync URL>, getToken }) }); getToken returns the current JWT.
   Call accord.start(); accord.stop() on logout.
3. Wrap the app in AccordProvider, passing the client as its client prop.
In components: useRecord(id) to read, useAccord() to write (assign, inc, add, remove, resolve),
useRecords(type) for lists, useSyncStatus() for pending writes and lastError.
Pick a merge rule for every field, deliberately:
- lww(): the latest write wins. Names, notes, simple scalars.
- counter(): every increment is summed, none is lost. Quantities, stock adjustments.
- set(): add-wins set of elements. Tags, assigned people, attached documents.
- conflict(): concurrent values are all kept and flagged; a person decides. Use it for
  status, approvals, amounts and anything with money or legal weight. Never lww() there.
UI:
- accord.on("refused", (r) => ...): the write was already rolled back; tell the user (r.reason).
- useConflicts(): show every value of a conflicted field where someone can choose, then
  accord.resolve(record, field, value).
Do not:
- set deviceId: the client generates and stores one; a fixed id can get writes refused.
- check the network before writing: writes are local and sync catches up.
- edit or replay ops, or write to the accord_ tables yourself.
- copy records into React state or a store: read them with the hooks.
Verify: open the app in two browser profiles, write in both while one is offline (DevTools),
reconnect, and check both show the same data and the conflict.
Docs: https://accord.benhattab.pro/docs/react/ https://accord.benhattab.pro/docs/client/