Labsco
clickhouse logo

clickhouse-js-node-coding

✓ Official321

by clickhouse · part of clickhouse/clickhouse-js

Reference: https://clickhouse.com/docs/integrations/javascript

🔥🔥🔥✓ VerifiedFreeQuick setup
🧰 Not standalone. This skill ships with clickhouse/clickhouse-js and only works together with that tool — install the tool first, then add this skill.

Reference: https://clickhouse.com/docs/integrations/javascript

Inspect the full instructions your agent will receiveExpand

This is the exact playbook injected into your agent when the skill activates — shown here so you can audit it before installing. You don't need to read it to use the skill.

by clickhouse

Reference: https://clickhouse.com/docs/integrations/javascript npx skills add https://github.com/clickhouse/clickhouse-js --skill clickhouse-js-node-coding Download ZIPGitHub321

ClickHouse Node.js Client — Coding

Reference: https://clickhouse.com/docs/integrations/javascript

⚠️ Node.js runtime only. This skill covers the @clickhouse/client package running in a Node.js runtime exclusively — including Next.js Node runtime API routes, React Server Components, Server Actions, and standard Node.js processes. Do not apply this skill to browser client components, Web Workers, Next.js Edge runtime, Cloudflare Workers, or any usage of @clickhouse/client-web. For browser/edge environments, the correct package is @clickhouse/client-web.

Task Index

Identify the user's task and read the matching reference file.

Task Triggers / symptoms Reference file Configure / connect the client Building a createClient call, URL parameters, clickhouse_settings, default format, custom HTTP headers reference/client-configuration.md Compress requests / responses compression, gzip vs zstd, { codec } option shape, Node version requirements, web limitations reference/compression.md Ping the server Health checks, readiness probes, "is ClickHouse up?" reference/ping.md Choose an insert format "Which format should I use to insert?", JSON vs raw, JSONEachRow vs JSON vs JSONObjectEachRow reference/insert-formats.md Insert into a subset of columns / different database insert({ columns }), excluding columns, ephemeral columns, cross-DB inserts reference/insert-columns.md Insert values, expressions, dates, decimals INSERT … VALUES with SQL functions, Date/DateTime from JS, Decimal precision, INSERT … SELECT; inserting a UUID into a UInt128 column is tricky — use when the user is writing code that stores a UUID as UInt128 reference/insert-values.md Async inserts (server-side batching) async_insert=1, fire-and-forget vs wait-for-ack reference/async-insert.md Select and parse results JSONEachRow reads, JSON with metadata, picking a select format reference/select-formats.md Parameterize queries Binding values, special characters / escaping, "SQL injection?", {name: Type} syntax reference/query-parameters.md Sessions & temporary tables session_id, CREATE TEMPORARY TABLE, per-session SET commands reference/sessions.md Modern data types Dynamic, Variant, JSON (object), Time, Time64, QBit (vector search) reference/data-types.md Custom JSON parse/stringify Plug in JSONBig / safe-stable-stringify / a BigInt-aware serializer reference/custom-json.md

Conventions used in answers

  • Always show import { createClient } from '@clickhouse/client' (Node, never Web).

  • Always await client.close() at the end of self-contained snippets; in long-running services, close on graceful shutdown.

  • For inserts, prefer format: 'JSONEachRow' and values: [...] unless the user's scenario requires otherwise.

  • For selects, prefer await (await client.query({...})).json<RowType>() for small / medium result sets; for bigger results suggest streaming.

  • When showing parameter binding, use ClickHouse's native {name: Type} syntax — never $1, ?, or :name.

  • For DDL inside a cluster or behind a load balancer, set clickhouse_settings: { wait_end_of_query: 1 } on the command() call so the server only acknowledges after the change is applied. See https://clickhouse.com/docs/en/interfaces/http/#response-buffering.

Out of scope

This skill covers day-to-day coding against @clickhouse/client (Node). The following topics are intentionally not covered here:

  • Errors, hangs, type mismatches, proxy pathname surprises, log silence, socket hang-ups, ECONNRESET → use the clickhouse-js-node-troubleshooting skill.

  • Streaming, Parquet, file streams, server-side bulk moves, progress streaming, async-insert throughput tuning — see examples/node/performance/.

  • TLS, RBAC / read-only users, deeper SQL-injection guidance — see examples/node/security/.

  • CREATE TABLE patterns, deployment-shaped connection strings, replication / sharding choices — see examples/node/schema-and-deployments/.

  • Browser, Web Worker, Next.js Edge, Cloudflare Workers — use @clickhouse/client-web and see examples/web/.

Still Stuck?