Requirements
- Node.js 18 or higher
npm,yarn, orpnpm
Installation
Setup
Get an API token
Obtain your API token from the Hatchet Cloud dashboard or your self-hosted Hatchet instance.The token is a JWT that embeds your tenant ID and server addresses so the SDK can read them automatically.
Set environment variables
Export your token so the SDK picks it up automatically:For self-hosted deployments, also set the host and port:
Initialize the client
Create a shared client instance to reuse across your application:With
hatchet-client.ts
HATCHET_CLIENT_TOKEN set, no additional configuration is required.Environment variable reference
| Variable | Description | Default |
|---|---|---|
HATCHET_CLIENT_TOKEN | API token (required) | — |
HATCHET_CLIENT_HOST_PORT | gRPC server host and port | Read from token |
HATCHET_CLIENT_NAMESPACE | Namespace prefix for workflow and event names | "" |
HATCHET_CLIENT_TLS_STRATEGY | TLS strategy (tls, mtls, or none) | "tls" |
The SDK validates that
HATCHET_CLIENT_TOKEN is a valid JWT. Tokens from the dashboard start with ey — if you see an error about token format, make sure you are copying the full token value.