R2D1 / TYPESCRIPT

Document storage and indexed queries for TypeScript.

Use one R2D1 collection API on Node.js or Cloudflare Workers. R2 stores complete documents; D1 stores a rebuildable index.

TSNODE.JS + WORKERS
RUNTIME SUPPORT

Choose your runtime.

The package provides separate adapters for Node.js and Cloudflare Workers.

NODE.JS

Node.js 22+

Use the Node.js R2 and D1 adapters. The R2 adapter uses the AWS S3 SDK.

Node.js setup →
CLOUDFLARE

Cloudflare Workers

Use Workers R2 and D1 bindings. Core and Workers adapters do not import Node.js modules.

Workers setup →
INSTALL

Add the package.

Install R2D1 from npm, then choose the adapter for your runtime.

npm install @nexcraft-dev/r2d1
R2D1

Compatible storage contracts.

R2 keys, D1 schema, and cursors follow the Java contracts. Document bytes use your codec. JSON is an explicit option, not a default format.

Read the TypeScript guide →