Skip to main content
Version: React SDK

Reference

ScreebProvider props

PropTypeRequiredDefaultDescription
websiteIdstringYes-Your website/channel ID from Screeb workspace settings
userIdstringNo-The unique identifier of your user
userPropertiesPropertyRecordNo-Properties of your user (max 128 char per name, 1000 attributes max)
hooksHooksInitNo-Global callback hooks for Screeb events
languagestringNoBrowser languageForce a specific language (e.g., "en", "fr")
shouldLoadbooleanNotrueWhether Screeb should load (set to false in SSR/CI environments)
autoInitbooleanNofalseAutomatically initialize Screeb when provider mounts
optionsScreebOptionsNo-Advanced SDK options (window context for iframes, custom endpoints)

useScreeb() methods

All methods return a Promise and should be awaited.

MethodDescription
close()Shutdown current Screeb session
debug()Print SDK state to console
eventTrack(name, properties?)Track a custom event with optional properties
identity(userId, properties?)Change current user identity (closes running surveys)
identityGet()Retrieve current user identity information
identityGroupAssign(groupName, groupType?, properties?)Assign current user to a group
identityGroupUnassign(groupName, groupType?)Unassign current user from a group
identityProperties(properties)Add properties to current user (set to null to delete)
identityReset()Reset current user identity (creates new anonymous user)
init(websiteId, userId?, properties?, hooks?, language?)Initialize Screeb SDK manually (not needed if autoInit is true)
load(options?)Load Screeb tag into DOM (called automatically if shouldLoad is true)
messageClose()Close currently running message
messageStart(messageId, allowMultiple?, hiddenFields?, hooks?, language?)Start a message programmatically
sessionReplayStart()Start recording a session replay
sessionReplayStop()Stop recording a session replay
surveyClose()Close currently running survey
surveyStart(surveyId, distributionId?, allowMultiple?, hiddenFields?, hooks?, language?, selectors?)Start a survey programmatically
targetingCheck()Force a targeting check to evaluate if surveys should display
targetingDebug()Print targeting engine state and rule evaluation results

Type definitions

PropertyRecord

type PropertyType = number | boolean | string | Date | PropertyRecord;

type PropertyRecord = {
[key: string]: PropertyType | PropertyType[];
};

HooksInit

Global hooks for all surveys and messages. See Hooks for all available hooks.

type HooksInit = {
version: string;
onReady?: (payload: any) => void;
onSurveyDisplayAllowed?: (payload: any) => boolean;
onMessageDisplayAllowed?: (payload: any) => boolean;
onSurveyShowed?: (payload: any) => void;
onSurveyStarted?: (payload: any) => void;
onQuestionReplied?: (payload: any) => void;
onSurveyCompleted?: (payload: any) => void;
onSurveyHidden?: (payload: any) => void;
onMessageShowed?: (payload: any) => void;
onMessageStarted?: (payload: any) => void;
onMessageCompleted?: (payload: any) => void;
onMessageHidden?: (payload: any) => void;
};

HooksSurveyStart

Hooks specific to a single survey started with surveyStart().

type HooksSurveyStart = {
onSurveyShowed?: (payload: any) => void;
onSurveyStarted?: (payload: any) => void;
onQuestionReplied?: (payload: any) => void;
onSurveyCompleted?: (payload: any) => void;
onSurveyHidden?: (payload: any) => void;
};

HooksMessageStart

Hooks specific to a single message started with messageStart().

type HooksMessageStart = {
onMessageShowed?: (payload: any) => void;
onMessageStarted?: (payload: any) => void;
onQuestionReplied?: (payload: any) => void;
onMessageCompleted?: (payload: any) => void;
onMessageHidden?: (payload: any) => void;
};

ScreebOptions

Advanced options for SDK initialization.

type ScreebOptions = {
window?: Window; // Use for iframe integration
screebEndpoint?: string; // Custom API endpoint (internal use only)
sdkName?: string; // SDK name (set automatically)
sdkVersion?: string; // SDK version (set automatically)
};

ScreebIdentityGetReturn

Return type of identityGet().

type ScreebIdentityGetReturn = {
anonymous_id: string;
user_id: string | null;
session_id: string;
session_start: string;
session_end: string;
channel_id: string;
is_ready: boolean;
};