$ show supabase/supabase-js
This is the Supabase JavaScript SDK monorepo, providing isomorphic client libraries for Supabase backend services. It is a well-structured TypeScript monorepo managed with pnpm and Nx, containing six core packages: auth-js (authentication), postgrest-js (database queries via PostgREST), realtime-js (WebSocket-based realtime subscriptions), storage-js (file storage and vector index API), functions-js (edge function invocation), and the umbrella supabase-js package that combines them into a single `createClient()` entry point. The SDK supports multiple runtimes (Node.js, Deno, browsers, Bun, React Native, Cloudflare Workers) and includes optional OpenTelemetry tracing support. The codebase demonstrates high craftsmanship with extensive TypeScript generics for type-safe query building, fluent builder patterns, robust error handling hierarchies, and comprehensive integration tests against local Supabase infrastructure. It is actively maintained with frequent releases, automated CI/CD, and a strong focus on backward compatibility.
The LLM identified 8 files worth highlighting for reuse:
Implements exponential backoff retry logic for idempotent HTTP methods (GET/HEAD/OPTIONS). Retries on 503, 520, or network errors, respects Retry-After headers, and can be disabled per-request. Isolated and reusable in any fetch-based client.
Environment-aware WebSocket constructor detection. Supports browser, Node.js 22+, Edge Runtime, Cloudflare Workers, and Deno. Provides helpful error messages when WebSocket is unavailable. Easily extractable for any project needing cross-runtime WebSocket support.
Binary/JSON message serializer for Phoenix-compatible realtime channels. Handles metadata filtering, UTF-8 event names, and length limits. Encodes and decodes between protocol versions. Self-contained and reusable for any WebSocket messaging layer.
Base class for storage API clients providing `handleOperation` method that catches typed errors (StorageError subclasses) and returns `{data, error}` tuples. Throws on unknown errors. Demonstrates a clean pattern for consistent error handling across multiple API surfaces.
Provides exclusive lock primitives using `navigator.locks` (browser) or a process-level lock (Node.js) with timeout and steal recovery. Marked deprecated but still functional. A reusable concurrency control pattern for any single-threaded environment.
WebAuthn browser API wrapper with serialization helpers for credential creation options and responses. Handles base64url/ArrayBuffer conversion with native Level 3 fallback. Includes `WebAuthnAbortService` singleton for ceremony cancellation. Isolated and reusable for any passkey implementation.
Parses W3C traceparent headers into structured objects with version, trace ID, span ID, and trace flags. Validates format and returns null for invalid headers. A small, self-contained utility for distributed tracing propagation.
Chainable filter builder with extensive TypeScript generics for type-safe database queries. Supports eq, gt, like, contains, textSearch, and many more operators. Each method returns a new builder instance with immutable headers. Demonstrates advanced generic programming for compile-time query validation.