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

@1kbirds/palimpsest-client

v0.1.0

Published

Type-safe TypeScript wrapper around palimpsest-client-js, with React hooks.

Readme

@1kbirds/palimpsest-client

Type-safe TypeScript wrapper around palimpsest-client-js (the wasm-pack --target web bundle), with React hooks.

The wasm bundle handles transport, codec, and reconnection. This package adds:

  • Strongly-typed subscriptions: declare a row type once, client.subscribe<Post>(sql) projects each diff into typed objects.
  • Schema-aware row decoder with optional per-column overrides (custom JSON parsing, bigint → number coercion, etc.).
  • React hooks (usePalimpsestClient, usePalimpsestSubscription) that handle wasm init, connection caching, and tear-down — no manual lifecycle in your components.

The package has zero runtime coupling to a specific wasm bundle location. You import the wasm-pack output yourself and pass the module to PalimpsestClient.connect, which keeps the package bundler-agnostic (Vite, webpack, esbuild, Rollup all work).

Install

In a monorepo with the wasm crate built into a sibling directory:

{
  "dependencies": {
    "@1kbirds/palimpsest-client": "^0.1.0",
    "react": "^18.3.1"
  }
}

The wasm bundle (built via wasm-pack build crates/palimpsest-client-js --target web) is imported directly from your app.

Quick start (vanilla TS)

import { PalimpsestClient } from "@1kbirds/palimpsest-client";
import * as wasm from "./pkg/palimpsest_client_js";

interface Post {
  id: bigint;
  title: string;
  published: boolean;
}

const client = await PalimpsestClient.connect({
  url: "http://localhost:50051",
  wasm,
});

const sub = await client.subscribe<Post>(
  "SELECT id, title, published FROM posts",
);

sub.onEvent((event) => {
  switch (event.kind) {
    case "accepted":
      console.log("schema:", event.schema);
      break;
    case "diff":
      console.log(event.op, event.rows);  // Post[]
      break;
    case "resync":
      console.warn("resync:", event.reason);
      break;
    case "error":
      console.error(event.code, event.message);
      break;
  }
});

// later
await sub.unsubscribe();
await client.shutdown();

Quick start (React)

import { useMemo } from "react";
import {
  usePalimpsestClient,
  usePalimpsestSubscription,
} from "@1kbirds/palimpsest-client/react";
import * as wasm from "./pkg/palimpsest_client_js";

interface Post {
  id: bigint;
  title: string;
  published: boolean;
}

export function App() {
  const opts = useMemo(
    () => ({ url: "http://localhost:50051", wasm }),
    [],
  );
  const { client } = usePalimpsestClient(opts);

  const { status, rows, error } = usePalimpsestSubscription<Post>(
    client,
    "SELECT id, title, published FROM posts",
  );

  if (status !== "open") return <p>status: {status}</p>;
  if (error) return <pre>{error.message}</pre>;
  return (
    <ul>
      {rows.map((p) => (
        <li key={String(p.id)}>
          #{String(p.id)} {p.title}
        </li>
      ))}
    </ul>
  );
}

Row decoders

The wasm side widens Postgres bigint/numeric columns to JS bigint and string respectively to avoid silent precision loss. If your app prefers plain number for small integers, pass a column-level decoder:

const sub = await client.subscribe<Post>(sql, {
  decoder: {
    coerceSafeIntegersToNumber: true,
    decoders: {
      created_at: (v) => new Date(String(v)),
    },
  },
});

Decoders attached on the client (PalimpsestClient.connect({ decoder })) apply to every subscription; per-subscription decoders override them.

What's typed today vs. in flight

The wire protocol delivers a snapshot (accepted + initial rows) synchronously; live diffs over the same subscription will arrive once the server's WAL-streaming path is wired through SubscriptionRouter::pump_cursor (see DESIGN.md §18.5). Until then, set refreshKey on the hook to force a fresh subscribe after a write — the hook supports this without any other code changes.

Subpaths

  • @1kbirds/palimpsest-client — core (PalimpsestClient, TypedSubscription, types). No React dependency.
  • @1kbirds/palimpsest-client/react — hooks. Pulls react as a peer.