Reference
ScreebProvider props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
websiteId | string | Yes | - | Your website/channel ID from Screeb workspace settings |
userId | string | No | - | The unique identifier of your user |
userProperties | PropertyRecord | No | - | Properties of your user (max 128 char per name, 1000 attributes max) |
hooks | HooksInit | No | - | Global callback hooks for Screeb events |
language | string | No | Browser language | Force a specific language (e.g., "en", "fr") |
shouldLoad | boolean | No | true | Whether Screeb should load (set to false in SSR/CI environments) |
autoInit | boolean | No | false | Automatically initialize Screeb when provider mounts |
options | ScreebOptions | No | - | Advanced SDK options (window context for iframes, custom endpoints) |
useScreeb() methods
All methods return a Promise and should be awaited.
| Method | Description |
|---|---|
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;
};