Installation
Install usagey in the server application that performs entitlement checks and records usage.
- npm
- pnpm
- Yarn
- Bun
npm install @usagey/sdk
pnpm add @usagey/sdk
yarn add @usagey/sdk
bun add @usagey/sdk
Requirements
- Node.js
20.19.0or newer. - A server-side JavaScript or TypeScript runtime.
- A Usagey Sandbox or Production API key from Developer > API keys.
The package includes TypeScript declarations. No separate @types package is required.
Add your API key
Use a Sandbox key while developing:
.env
USAGEY_API_KEY=usg_test_replace_me
Production keys begin with usg_live_. Store the key in your deployment platform's encrypted environment variables and never prefix it with NEXT_PUBLIC_, VITE_, or another client-exposed convention.
Create the client
import { Usagey } from "@usagey/sdk";
export const usagey = new Usagey(process.env.USAGEY_API_KEY!);
The SDK infers Sandbox or Production from the API-key prefix. Continue to Configuration for explicit environment and timeout options.