Introducing Nipworker...! the nostr library powering @Nuts π₯, it's a big chunk, it comes quite opinionated, but it's a good mix of speed and efficiency. It's build around FlatBuffers and heavy uses of web workers, compiled from rust to wasm.
Works with any frontend. No React dependency, no Svelte stores to learn, no Vue composables. Just hook-like methods with callbacks that you wire to your framework's reactivity however you want.
4 Dedicated Workers
β’ Connections β Relay connections, WebSocket lifecycle, reconnection backoff. Owns all network I/O.
β’ Cache β Stores FlatBuffers in ring buffers in real time and IndexedDB in timeout chunks. No refetching what you already have.
β’ Parser β Event validation, signature verification, content parsing. Receives raw JSON from relays, outputs FlatBuffers to your frontend. No JSON.parse on the main thread. Ever.
β’ Crypto β Signing, NIP:04/44 encryption, NIP:46 remote signer sessions, Cashu proof verification.
Each worker runs in its own Web Worker. The main thread just orchestrates. Heavy work happens in parallel.
FlatBuffers Instead of JSON
NIPWorker speaks FlatBuffers end to end. Raw relay messages get parsed once in Rust, then flow through the system as zero:copy binary views. No JSON.parse. No object allocation. No GC pauses on infinite scroll.
Your components read directly from FlatBuffers tables. A Kind1 note's content blocks (images, videos, hashtags) arrive pre:parsed. You iterate them with fbArray() and render straight from the binary buffer to the DOM. The schema lives from wire to HTML.
Apollo:Inspired State Management
Like Apollo Client, NIPWorker IS your store. You do not need Redux, Zustand, or custom state libraries.
useSubscribe pulls FlatBuffers from the worker pool and feeds your UI directly. Subscriptions accept fetch policies: cacheFirst serves from memory immediately if available, noCache always bypass the cache and hits the network. You control the speed versus freshness tradeoff per query.
usePublish sends events and tracks relay acknowledgments. Your entire app state flows through these two hooks. Subscriptions are deduped across components automatically. The library manages the cache, merge logic, and reactive updates.
Pipeline Architecture
Events flow through a processing pipeline: verify β dedupe β filter β transform β store. Each subscription configures its own pipeline. The pipeline runs in the Parser worker before FlatBuffers reach your callback.
Opinionated by Design
NIPWorker enforces outbox model by default. It reads every author's NIP:65 relay list to discover where they publish. The library manages relay discovery and publication strategy for you.
Built for clients that need to render thousands of events without dropping frames.
npm install @candypoets/nipworker
npx skills add candypoets/skills@nipworker

GitHub
GitHub - candypoets/nipworker: Nostr client library with worker-based architecture using Rust WASM
Nostr client library with worker-based architecture using Rust WASM - candypoets/nipworker
