Installation
Requirements
- Node.js 22 or newer. The SDK's engine is runtime-agnostic, but the published packages target Node today.
- A Cloudflare R2 bucket, plus an API token for it (see R2 credentials below).
SDK
npm i @ver2/sdk @aws-sdk/client-s3@aws-sdk/client-s3 is an optional peer dependency. It is only needed for @ver2/sdk/s3, the R2 storage driver. The in-memory store at @ver2/sdk/memory needs nothing extra, which makes it handy in tests.
The package has three entry points:
| Import | What it gives you |
|---|---|
@ver2/sdk | createVer2, the Ver2 client, errors, types |
@ver2/sdk/s3 | S3ObjectStore, the driver for R2 |
@ver2/sdk/memory | MemoryObjectStore, an in-memory store for tests |
CLI
npm i -g @ver2/cli
ver2 --helpOr run it without installing:
npx @ver2/cli --helpFrom source
git clone https://github.com/JBuxo/ver2.git
cd ver2
npm install
npm run build
node cli/dist/index.js --helpR2 credentials
veR2 talks to R2 through its S3-compatible API, so it needs an R2 API token:
- In the Cloudflare dashboard, open R2 and note your account ID.
- Go to Manage API tokens → Create API token.
- Give it Object Read & Write permission, scoped to the bucket you want to version.
- Copy the access key ID and secret access key. The secret is shown only once.
You now have the four values veR2 needs: account ID, bucket name, access key ID and secret access key.
Keep credentials in environment variables or a git-ignored .env.local, never in code. veR2 never logs them.
Next: Quickstart: SDK or Quickstart: CLI.