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 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
Server-side user signing
For secure SSO, sign the user on your server with your secret key and pass the resulting token to the client as userToken.
// 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
});