Installation
Install the SDK from npm:
- npm
- yarn
- pnpm
npm install @decrackle/sdk
yarn add @decrackle/sdk
pnpm add @decrackle/sdk
Importing
The package ships both ESM and CommonJS builds.
ESM (recommended)
import { Decrackle } from '@decrackle/sdk';
CommonJS
const { Decrackle } = require('@decrackle/sdk');
TypeScript
TypeScript types are bundled — no separate @types package needed. The SDK requires TypeScript 4.7 or later.
Custom fetch
By default the SDK uses the global fetch built into Node.js 18+. If you need a custom implementation (proxy, test mock, edge runtime), pass it via the fetch option:
import { Decrackle } from '@decrackle/sdk';
import fetchWithProxy from 'node-fetch';
const client = new Decrackle({
apiKey: process.env.DECRACKLE_API_KEY,
fetch: fetchWithProxy as typeof globalThis.fetch,
});