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

@kalamdb/react

v0.5.1-beta.2

Published

React bindings for KalamDB live queries and mutation state

Readme

@kalamdb/react

React bindings for KalamDB live queries. The package exposes hook-first APIs plus thin component wrappers over the shared @kalamdb/client live controller.

Install

npm install @kalamdb/react @kalamdb/client react react-dom

Typed Drizzle query mode also needs @kalamdb/orm and drizzle-orm:

npm install @kalamdb/orm drizzle-orm

Basic Usage

import { KalamProvider, LiveQuery } from '@kalamdb/react';
import { createClient } from '@kalamdb/client';

const client = createClient({ url: 'http://localhost:2900' });

export function App() {
  return (
    <KalamProvider client={client}>
      <LiveQuery query="SELECT * FROM chat.messages WHERE room = 'main' ORDER BY created_at ASC">
        {({ rows, state, insert }) => (
          <section>
            {state.loading ? <p>Loading...</p> : null}
            {rows.map((row) => <p key={row.id.asString()}>{row.body.asString()}</p>)}
            <button
              disabled={state.inserting}
              onClick={() => insert('chat.messages', { room: 'main', body: 'Hello' })}
            >
              Send
            </button>
          </section>
        )}
      </LiveQuery>
    </KalamProvider>
  );
}

Raw SQL live mode supports the live-compatible subset in v1. Ordering and limits are normalized into client-side projections where possible; unsupported SQL shapes fail with a descriptive error.

Typed Live Queries

Use typed mode when you already have a Drizzle schema from @kalamdb/orm.

import { LiveQuery } from '@kalamdb/react';
import { asc, eq } from 'drizzle-orm';
import { messages } from './schema.generated';

export function MessagesPane({ conversationId }: { conversationId: string }) {
  return (
    <LiveQuery
      table={messages}
      where={(table) => eq(table.conversationId, conversationId)}
      orderBy={(table) => asc(table.createdAt)}
      deps={[conversationId]}
    >
      {({ rows, state, insert }) => (
        <section>
          {rows.map((row) => <article key={row.id}>{row.body}</article>)}
          <button
            disabled={state.inserting}
            onClick={() => insert(messages).values({
              id: crypto.randomUUID(),
              conversationId,
              role: 'user',
              body: 'Hello',
              status: 'sent',
              createdAt: new Date(),
              updatedAt: new Date(),
            })}
          >
            Send
          </button>
        </section>
      )}
    </LiveQuery>
  );
}

Multiple Live Datasets

useLiveQueries and LiveQueries open one controller per named query and return a typed context for each dataset plus aggregate mutation and connection state.

import { useLiveQueries, useLiveSelection } from '@kalamdb/react';
import { asc, eq } from 'drizzle-orm';
import { approvals, messages, toolCalls, typing } from './schema.generated';

export function AssistantWorkspace({ conversationId }: { conversationId: string }) {
  const live = useLiveQueries({
    queries: {
      messages: {
        table: messages,
        where: (table) => eq(table.conversationId, conversationId),
        orderBy: (table) => asc(table.createdAt),
        deps: [conversationId],
      },
      typing: { table: typing, where: (table) => eq(table.conversationId, conversationId), deps: [conversationId] },
      toolCalls: { table: toolCalls, where: (table) => eq(table.conversationId, conversationId), deps: [conversationId] },
      approvals: { table: approvals, where: (table) => eq(table.conversationId, conversationId), deps: [conversationId] },
    },
    deps: [conversationId],
  });

  const assistant = useLiveSelection(live, (context) => ({
    messages: context.messages.rows,
    typingUsers: context.typing.rows.map((row) => row.userName),
    activeTools: context.toolCalls.rows.filter((row) => row.status !== 'completed'),
    pendingApprovals: context.approvals.rows.filter((row) => row.status === 'pending'),
    approve: (approvalId: string) => context.update(approvals, approvalId).set({ status: 'approved' }),
  }));

  return <AssistantLayout {...assistant} busy={live.state.loading || live.state.updating} />;
}

Rows remain authoritative from KalamDB live streams. Mutation state is local UI state for disabling buttons, showing spinners, and surfacing errors; it does not mutate row data optimistically.

React AI Chat Example

The repository includes a standalone validation app in examples/react-ai-chat. It demonstrates conversation navigation, history loading, multi-file messages, typing state, streamed assistant activity, tool calls, and human approvals using @kalamdb/react.

cd examples/react-ai-chat
npm install
npm run setup
npm run dev

The example defaults to demo mode so the React components are immediately usable without a server. Set VITE_KALAMDB_DEMO_MODE=false after applying chat-app.sql to a running KalamDB server.

License

Licensed under the Apache License, Version 2.0 (Apache-2.0). See the packaged LICENSE.txt and NOTICE files.