Loyalty
Docs

Search...

⌘K

Installation

Get up and running with the Loyalty SDK in your project. This guide covers prerequisites, installation, and initial configuration.

Prerequisites

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 SDK

Install the Loyalty SDK using your preferred package manager:

bash

npm install @loyalty/sdk

Or with yarn:

bash

yarn add @loyalty/sdk

Or with pnpm:

bash

pnpm add @loyalty/sdk

Environment Setup

Create 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_id

Keep your secrets safe

Never commit your API secret to version control. Make sure your .env.local file is included in your .gitignore.

Initialize the Client

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.