Skip to Content

TypeScript SDK Examples

The KalamDB repo now ships three smaller examples instead of a few product-sized demos.

They live in the repository under:

  • examples/simple-typescript
  • examples/chat-with-ai
  • examples/summarizer-agent

Each example has its own setup path and its own test.

1. Realtime Ops Feed

Repository path: examples/simple-typescript

What it demonstrates:

  • queryAll() for the initial SQL read
  • live() for live browser updates
  • browser auth with Auth.basic(...)
  • cross-tab realtime sync from one write

Why it matters:

This is the smallest browser example that still feels real. It avoids wrapper layers, keeps the full flow inside one React component, and shows the recommended pattern: one live query returns the current rows while USER-table isolation keeps each signed-in user inside their own data partition.

Run it:

cd examples/simple-typescript npm install npm run setup npm run dev

Test it:

npm test

The Playwright test opens two tabs, inserts one row, and verifies both tabs update.

2. Chat With AI

Repository path: examples/chat-with-ai

What it demonstrates:

  • writing to a shared table from the browser
  • topic fan-out from ALTER TOPIC ... ADD SOURCE ...
  • background work with runAgent()
  • live browser updates when the worker writes the reply row

Why it matters:

This example shows the table → topic → worker → browser loop without needing a large app shell or external auth setup.

Run it:

cd examples/chat-with-ai npm install npm run setup npm run agent npm run dev

Test it:

npm test

The Playwright test starts the agent, opens two tabs, sends a message, and waits for the assistant reply in both tabs.

3. Summarizer Agent

Repository path: examples/summarizer-agent

What it demonstrates:

  • a worker-only runAgent() example
  • row enrichment back into the source table
  • a failure sink table for exhausted retries

Why it matters:

If you do not need a browser at all, this is the cleanest place to start. It shows how little code is required to build a useful background worker around KalamDB topics.

Run it:

cd examples/summarizer-agent npm install npm run setup npm run start

Test it:

npm test

The integration test inserts a row and waits until the worker writes the summary back.

Last updated on