Skip to content

Installation & Authentication

The Hapnd CLI handles deploying reducers and projections, binding them to aggregate types, and checking compilation status.

No global install needed — run directly via npx:

Terminal window
npx @hapnd/cli <command>

Or install globally if you prefer:

Terminal window
npm install -g @hapnd/cli
hapnd <command>

Requires Node.js 20 or later.

Authenticate with your API key:

Terminal window
npx @hapnd/cli login sk_live_your_api_key

The CLI validates your key against the Hapnd API, then stores it in ~/.hapnd/config.json with 0600 file permissions (owner-only read/write).

API keys must start with sk_live_ or sk_test_.

The HAPND_API_KEY environment variable takes precedence over the stored config. Useful for CI/CD or ephemeral environments:

Terminal window
HAPND_API_KEY=sk_live_your_key npx @hapnd/cli deploy
Terminal window
npx @hapnd/cli whoami

Output:

✓ Authenticated
Tenant: My Company
Key: sk_live_abc1...ef23
Source: config

Shows your tenant name, a masked key, and whether the key came from the config file or the environment variable.

Clear stored credentials:

Terminal window
npx @hapnd/cli logout