SDK Installation

Install the Reflet SDK and configure it for your project.

Install

npm install reflet-sdk

Also works with yarn, pnpm, and bun.

Configuration

Create a client instance with your public API key:

import { Reflet } from "reflet-sdk";

const reflet = new Reflet({
  publicKey: "fb_pub_xxx", // from your Reflet dashboard
  user: {
    id: "user_123",
    email: "user@example.com",
    name: "Jane Doe",
  },
});

Configuration options

OptionTypeDescription
publicKeystringYour organization's public API key (fb_pub_xxx). Required.
userRefletUserUser identification for SSO. Optional.
userTokenstringPre-signed user token (alternative to user object). Optional.
baseUrlstringAPI base URL. Defaults to Reflet production API. Optional.

Server-side user signing

For secure SSO, sign the user on your server and pass the token to the client:

// Server
import { signUser } from "reflet-sdk/server";

const { token } = signUser(
  { id: user.id, email: user.email, name: user.name },
  process.env.REFLET_SECRET_KEY!
);

// Client
const reflet = new Reflet({
  publicKey: "fb_pub_xxx",
  userToken: token, // from your server
});