For the complete documentation index optimized for AI agents, see llms.txt.Queries for HelixDB can also be authored in TypeScript using the
@helix-db/helix-db package.
The TypeScript DSL builds the same JSON AST as the Rust helix-db
crate, so the resulting queries.json bundle is interchangeable. Use TypeScript when your service
is already Node.js or you want end-to-end type inference on parameters.
For the conceptual model and per-builder walkthrough, see the
Querying Guide.
Prerequisites
- Node.js 20 or later.
- A package manager (
npm,pnpm, oryarn). - Optional: the Helix CLI for deploying the resulting bundle.
Create a new project
@helix-db/helix-db is published as an ES module, so the "type": "module" field
in package.json matters. Skip this step if you are adding queries to an existing
ESM-configured project.
Add the dependency
tsx is optional but convenient for running the generator without a separate build step.
Minimal tsconfig.json
Author your queries
Queries are plain functions that return aReadBatch or WriteBatch. To bundle them,
declare their parameters with defineParams, wrap them with
registerRead / registerWrite, and collect them with defineQueries. The bundle’s
generate(path) method writes the same queries.json shape that the Rust
generate_to_path emits.
src/queries.ts
- The keys under
readandwritename each query in the bundle and back the typedqueries.call.*helpers (see below). Names must be unique across reads and writes — a duplicate throwsGenerateErrorat bundle time. PropertyInput.param("name")feeds a parameter into anaddNproperty bag or asetProperty; for predicates usePredicate.eqParam(...)and friends.
Add a generator entry point
src/generate.ts
queries.generate(path) writes the bundle and resolves to the path it wrote. The file
is laid out identically to the Rust bundle so the runtime treats them as equivalent.
Wire up the script
queries.json in the project root. From here you can:
- Mount it into the local
enterprise-devruntime asPATH_TO_QUERIES— see Local Development. - Deploy it to HelixDB through the control plane — see Working with HelixDB.
Sending registered queries from TypeScript
defineQueries also exposes a typed call map. Each entry takes the query’s
parameter values (inferred from defineParams) and returns a DynamicQueryRequest
you hand to the client’s .dynamic(...):
call.<name> is fully typed — an unknown key or wrong parameter type is a compile error — and
sets query_name to the route key so logs show user_by_username, not __dynamic__. See
Querying for the full client send path.
Next Steps
Querying Guide
Tutorial-style walkthrough of the DSL, from the simplest read to parameter-bound bundles.
Working with HelixDB
Deploy
queries.json and the runtime workflow.Local Development
Run the bundle locally with the
enterprise-dev image.npm package
@helix-db/helix-db on npm.