SDK Installation
Install the Reflet SDK and configure it for your project.
Install
npm install reflet-sdkAlso 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
| Option | Type | Description |
|---|---|---|
publicKey | string | Your organization's public API key (fb_pub_xxx). Required. |
user | RefletUser | User identification for SSO. Optional. |
userToken | string | Pre-signed user token (alternative to user object). Optional. |
baseUrl | string | API 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
});