@clickhouse/client

The official TypeScript client for connecting Node.js applications to ClickHouse over HTTP.

SDK
npm
v1.24.1
329 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
91 /100 Excellent
Development Activity 96
Maintenance 100
Community 84
Maturity 56
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
85 /100 Excellent
Architecture 88
Code Quality 92
Innovation 78
Learning Curve 80

@clickhouse/client is the official Node.js client for ClickHouse, the open-source column-oriented database built for real-time analytics. Written entirely in TypeScript with zero external runtime dependencies, it wraps Node’s built-in HTTP and Stream APIs to give applications a typed, promise-based interface for running queries, inserts, and commands against a ClickHouse server or ClickHouse Cloud.

The client is one of four packages published from the ClickHouse/clickhouse-js monorepo: @clickhouse/client (this package, Node.js-specific), @clickhouse/client-web (Fetch/Web Streams-based, for browsers and edge runtimes like Cloudflare Workers), @clickhouse/client-common (shared types and the base client framework both platform packages extend), and @clickhouse/datatype-parser (a standalone parser for ClickHouse’s column type strings). @clickhouse/client is the one most Node.js backends should install directly.

It supports streaming reads and writes for large result sets, a wide range of ClickHouse’s native data formats (JSONEachRow, CSV, native RowBinary, and more), configurable compression, session and query-level ClickHouse settings, JWT and basic auth, and OpenTelemetry-compatible tracing hooks. The project maintains an extensive integration test suite that runs against real ClickHouse instances, plus a dedicated ‘oss-dependents’ test suite that exercises the client the same way real downstream open-source projects (Umami, Cube, Nango, and others) actually use it in production, catching regressions before they reach consumers.

What You Get

  • A createClient() factory returning a typed NodeClickHouseClient with query, insert, exec, and command methods for every interaction pattern with ClickHouse.
  • Native streaming support in both directions: Stream.Readable result sets for large selects and streamable input values for inserts, so payloads never need to be fully buffered in memory.
  • Support for ClickHouse’s full range of data formats (JSON variants, CSV/TSV, native RowBinary via the companion parser) with typed helpers like resultSet.json() and resultSet.text().
  • Built-in connection-level features: gzip request/response compression, keep-alive HTTP agent pooling, JWT and basic auth, and per-query ClickHouse settings typed against ClickHouseSettings.
  • OpenTelemetry-shaped tracing primitives (ClickHouseTracer, ClickHouseSpan) so query spans can be wired into an existing observability pipeline without a separate instrumentation package.

Common Use Cases

  • Backing a real-time analytics dashboard or product-analytics tool (as done by projects like Umami) with sub-second aggregate queries over large event tables.
  • Bulk-loading application or log events into ClickHouse via streamed inserts, without holding entire batches in process memory.
  • Building an internal BI/reporting service that runs parameterized SQL against ClickHouse and streams JSON results back to a frontend.
  • Integrating ClickHouse as the storage/query layer inside a larger open-source tool (data pipeline platforms, log analytics, feature stores) via a stable, versioned client instead of hand-rolled HTTP calls.

Under The Hood

Architecture

The package is a thin Node.js-specific layer over a shared core: packages/client-node/src/client.ts defines NodeClickHouseClient, which extends the base ClickHouseClient exported from @clickhouse/client-common (re-exported locally under ./common/index), and createClient() simply instantiates that base class with a Node-specific impl object (NodeConfigImpl) supplying HTTP connection factories from src/connection/ (node_http_connection.ts, node_https_connection.ts, node_custom_agent_connection.ts, socket_pool.ts). This mirrors the equivalent client-web package, which supplies a Fetch/Web-Streams impl instead — so platform differences are isolated to the connection layer while query building, settings typing, result parsing, and error handling live once in client-common. The createClient() factory also accepts an injected connection, overriding the default HTTP factory entirely, which the code notes exists for an experimental chDB integration — evidence the connection abstraction is a deliberate seam, not an implementation detail leaking through.

Tech Stack

Written entirely in TypeScript (Node 20+ required) with an empty dependencies field in package.json — the published client has zero runtime dependencies, relying only on Node’s built-in http/https and stream modules for I/O. The monorepo root uses npm workspaces across packages/*, with typescript, eslint + typescript-eslint, prettier, and vitest (plus @vitest/coverage-v8/istanbul) as the shared toolchain; devDependencies for the node package add only simdjson for benchmarking. Builds run through plain tsc; the browser-facing sibling package additionally pulls in playwright and @vitest/browser-playwright for cross-browser testing.

Code Quality

Testing is extensive: 136 *.test.ts files across the monorepo (76 under client-node alone), split into unit tests (test:unit, mockable via CLICKHOUSE_TEST_SKIP_INIT), integration tests that run against real ClickHouse instances (test:integration, :tls, :local_cluster, :cloud), and a distinctive test:oss-dependents suite (__tests__/oss-dependents/) that exercises the client the way real downstream projects (Umami, Cube, Nango, Firecrawl, Daytona, and others) actually use it, catching breaking changes before they reach consumers. CI runs a dedicated workflow per test category (tests-node.yml, tests-web.yml, tests-bun.yml, tests-oss-dependents.yml, tests-dist.yml), plus husky + lint-staged pre-commit hooks, strict ESLint (--max-warnings=0), and a Scorecard security badge. Public APIs are fully typed, with generic DataFormat-parameterized return types (QueryResult<Format>) that narrow at compile time rather than relying on runtime checks.

API Design The public surface is intentionally small: createClient() plus a handful of methods (query, insert, exec, command) cover the entire interaction model, and format-specific typing (resultSet.json() vs .text()) is inferred from the format option passed at the call site rather than requiring separate methods per format. The README documents an explicit client-version-to-ClickHouse-version compatibility table, reducing upgrade guesswork, and values re-exported from the shared client-common package are re-bound locally specifically so @deprecated JSDoc tags don’t leak onto the recommended import path — a level of API surface curation that goes beyond typical wrapper packages.

Used by 38 apps in this directory

TypeScript
89%
Other

Hexclave

Authentication · Developer Tools

6,877

The open-source user infrastructure platform — authentication, teams, payments, emails, analytics, and more on a single unified user model.

View details
88
Repo Health
80
Technical
66
Dependency
Built with
TypeScript 89%
Updated 6 days ago
TypeScript
98%
Apache 2.0

superlog

AI Agents · Monitoring

1,469

Open-source agentic observability that ingests OpenTelemetry signals, groups them into incidents, and deploys AI agents to investigate and fix your production bugs automatically.

View details
66
Repo Health
73
Technical
72
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
97%
AGPL 3.0

Swetrix

Analytics

1,213

Privacy-first, cookieless web analytics with error tracking, session replays, and performance monitoring — self-host or use Cloud.

View details
87
Repo Health
71
Technical
66
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
Rust
79%
Apache 2.0

TensorZero

Ab Testing Experimentation · AI Development · Monitoring

11,708

TensorZero unifies the LLM gateway, observability, evaluation, optimization, and experimentation stack behind a single OpenAI-compatible API, built in Rust for sub-millisecond p99 latency.

View details
53
Repo Health
87
Technical
68
Dependency
Built with
Rust 79%
TypeScript 15%
Updated 4 months ago
TypeScript
98%
Apache 2.0

Tianji

Analytics · Monitoring

3,119

Replace Google Analytics, UptimeKuma, and Prometheus with one self-hosted platform that tracks websites, monitors uptime, and reports server health.

View details
86
Repo Health
76
Technical
64
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
HTML
68%
AGPL 3.0

ToolJet

AI Agents · Low Code Platforms · No Code Platforms

41,123

Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
HTML 68%
JavaScript 20%
Updated 6 days ago
TypeScript
79%
MIT

Trench

Analytics · Data Engineering · Monitoring

1,665

Open-source event tracking infrastructure built on Kafka and ClickHouse that handles thousands of events per second on a single node, with full Segment API compatibility and no cookies.

View details
44
Repo Health
81
Technical
73
Dependency
Built with
TypeScript 79%
MDX 15%
Updated 6 months ago
TypeScript
99%
Apache 2.0

Trigger.dev

AI Development · Automation · Developer Tools

16,606

Build and deploy fully-managed AI agents and background jobs in TypeScript — with no timeouts, durable retries, real-time observability, and elastic scaling built in.

View details
90
Repo Health
9
Technical
63
Dependency
Built with
TypeScript 99%
Updated 6 days ago
TypeScript
84%
Other

twenty

CRM

59,615

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript 84%
MDX 14%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers