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

automerge-react-suspense-hooks

v0.0.0

Published

A set of React hooks for working with [Automerge](https://automerge.org/) documents using React's [Suspense](https://react.dev/reference/react/Suspense)-based APIs.

Downloads

8

Readme

automerge-react-suspense-hooks

A set of React hooks for working with Automerge documents using React's Suspense-based APIs.

Note that Automerge includes a first-party React hooks integration; you may want to use that instead.

The official hooks do not integrate with Suspense, but see this pull request.

Installing

pnpm add automerge-react-suspense-hooks

Usage

All hooks must be used in children of the WithRepo context component:

import { Repo } from "@automerge/automerge-repo";
import { WithRepo } from "automerge-react-suspense-hooks";

export function AutomergeApp({ repo }: { repo: Repo }) {
  return (
    <WithRepo repo={repo}>
      <DocumentView>
    </WithRepo>
  )
}

Note that this component also acts as a Suspense boundary (though you may add other Suspense boundaries nested under it).

useDocument

To get the state of a single document, use useDocument:

/**
 * Retrieves the current state of the document (and causes a re-render whenever
 * the document changes). Suspends until the document is loaded.
 *
 * @param id the document to load
 * @throws @type DocumentDeletedException if the document is deleted
 * @throws @type DocumentUnavailableException if the document is unavailable
 * @returns the loaded document
 */
function useDocument<Document>(id: AnyDocumentId): Doc<Document>;

useDocumentSelection

To derive a state from several documents, or for watching a subset of a single document, use useDocumentSelection:

/**
 * Reduce the given set of documents to a single Selection. Watches the
 * specified documents for changes, but will only cause a re-render if
 * the changes effect a change in the Selection.
 *
 * @param ids list of documents to monitor
 * @param opts options (see @type UseDocumentsOpts)
 * @returns the derived Selection
 */
function useDocumentSelection<Document, Selection>(
  ids: AnyDocumentId[],
  opts?: UseDocumentsOpts<Document, Selection>,
): Selection;

The options are as follows:

/**
 * Options to useDocuments hook.
 */
type UseDocumentsOpts<Document, Selection = Document> = {
  /**
   * Selector to use (see below).
   */
  selector?: Selector<Document, Selection>;
  /**
   * Equality function to use with Selections, in order to determine whether to
   * re-render based on the new Selection.
   */
  equal?: EqualFn<Selection>;
};

Selectors transform a list of documents to a Selection:

/**
 * Reduce a list of documents to a selection.
 */
type Selector<Document, Selection> = (
  items: DocHandle<Document>[],
) => Selection;

The default selector returns a map of Automerge URL to current document state. The default equal implementation is a built-in deepEqual function.

useCreateDocument

/**
 * Returns a function that can be used to create documents in the current repo.
 *
 * @returns function that accepts an initial value and returns the new document's url
 */
function useCreateDocument<Document>();

useUpdateDocument

/**
 * Returns a function to update the given document. The function will be passed
 * the document's current state to mutate.
 *
 * @param id of document to update
 * @returns function to update the document
 */
export function useUpdateDocument<Document>(id: AnyDocumentId);