Search...
⌘KGet up and running with the Loyalty SDK in your project. This guide covers prerequisites, installation, and initial configuration.
Before installing the Loyalty SDK, make sure you have the following:
Node.js version 18 or higher is required. You can check your version with node --version. You'll also need a package manager like npm, yarn, or pnpm.
Install the Loyalty SDK using your preferred package manager:
bash
npm install @loyalty/sdkOr with yarn:
bash
yarn add @loyalty/sdkOr with pnpm:
bash
pnpm add @loyalty/sdkCreate a .env.local file in your project root and add your Loyalty API credentials:
env
LOYALTY_API_KEY=your_api_key_here
LOYALTY_API_SECRET=your_api_secret_here
LOYALTY_PROGRAM_ID=your_program_idKeep your secrets safe
Never commit your API secret to version control. Make sure your .env.local file is included in your .gitignore.
Create a Loyalty client instance in your application:
typescript
import { LoyaltyClient } from "@loyalty/sdk";
const loyalty = new LoyaltyClient({
apiKey: process.env.LOYALTY_API_KEY!,
apiSecret: process.env.LOYALTY_API_SECRET!,
programId: process.env.LOYALTY_PROGRAM_ID!,
});
export default loyalty;Next steps
Now that you have the SDK installed, head over to the Configuration guide to set up your loyalty program rules.