Contentful Personalization & Analytics
    Preparing search index...

    Props for the OptimizationRoot component.

    Accepts all CoreStatefulConfig properties directly. Only clientId is required.

    interface OptimizationRootProps {
        allowedEventTypes?: AllowedEventType[];
        api?: CoreStatefulApiConfig;
        children: ReactNode;
        clientId: string;
        contentful?: ContentfulConfig;
        defaults?: CoreConfigDefaults;
        environment?: string;
        eventBuilder?: EventBuilderConfig;
        fetchOptions?: Omit<ProtectedFetchMethodOptions, "apiName">;
        getAnonymousId?: () => string | undefined;
        liveUpdates?: boolean;
        locale?: string;
        logLevel?: LogLevels;
        onEventBlocked?: (event: BlockedEvent) => void;
        onStatesReady?: OnStatesReady;
        prefetchManagedEntries?: readonly ManagedEntryDescriptor[];
        queuePolicy?: QueuePolicy;
        trackEntryInteraction?: Partial<Record<EntryInteraction, boolean>>;
    }

    Hierarchy (View Summary)

    Index

    Properties

    allowedEventTypes?: AllowedEventType[]

    Allow-listed event type strings permitted when consent is not set.

    Unified API configuration for stateful environments.

    children: ReactNode

    Children components that will have access to the ContentfulOptimization instance.

    clientId: string

    Client identifier used for authentication or tracking.

    contentful?: ContentfulConfig

    Optional SDK-managed Contentful Delivery API entry fetching.

    Existing manual resolveOptimizedEntry() usage remains supported. Configure this only when callers want the SDK to fetch explicit entry IDs through contentful.js.

    Optional set of default values applied on initialization.

    environment?: string

    Contentful environment identifier.

    'main'

    eventBuilder?: EventBuilderConfig

    Event builder configuration (channel/library metadata, etc.).

    fetchOptions?: Omit<ProtectedFetchMethodOptions, "apiName">

    Options used to configure the underlying protected fetch method.

    apiName is derived from the client name and must not be provided here.

    getAnonymousId?: () => string | undefined

    Function used to obtain an anonymous user identifier.

    liveUpdates?: boolean

    Whether OptimizedEntry components react to state changes in real time.

    false

    Live updates are always enabled when the preview panel is open, regardless of this setting.

    locale?: string

    Default SDK locale used for Experience API requests and event context.

    logLevel?: LogLevels

    Minimum log level for the default console sink.

    onEventBlocked?: (event: BlockedEvent) => void

    Callback invoked whenever an event call is blocked by checks.

    onStatesReady?: OnStatesReady

    Called once SDK state initialization completes and before provider children mount. Return a cleanup function to unsubscribe app-level state observers on teardown.

    prefetchManagedEntries?: readonly ManagedEntryDescriptor[]

    Managed entries to prefetch after the SDK is ready.

    queuePolicy?: QueuePolicy

    Unified queue policy for queued stateful work.

    trackEntryInteraction?: Partial<Record<EntryInteraction, boolean>>

    Controls which entry interactions are tracked automatically for all OptimizedEntry components. Individual components can override each interaction type with their trackViews and trackTaps props.

    { views: true, taps: true }

    Mirrors React Web's trackEntryInteraction pattern. Uses taps instead of clicks to match React Native terminology.

    <OptimizationRoot
    clientId="your-client-id"
    trackEntryInteraction={{ taps: false }}
    >
    <App />
    </OptimizationRoot>