JavaScript SDK: The Ninetailed Instance

Leverage custom instantiation options, methods, and properties for precise control over accessing profile data, rendering experiences, and tracking functions.

The Javascript SDK facilitates sending core Ninetailed events and tracking Ninetailed Experience views. These functions are managed by a created Ninetailed class instance. Internally, the instance uses a NinetailedApiClient instantiated by the Shared SDK.

A Ninetailed instance is created and provided when using the <NinetailedProvider> of React-based Ninetailed SDKs.

Because a Ninetailed class instance contains methods for tracking Experience views, it is mostly intended to be used client-side. For implementations where you want to render Experiences on the server, check out the Shared SDK's underlying NinetailedApiClient.

Want to browse the code? Check out the Ninetailed instance in our open source SDK.

Dependencies and Instantiation

Ninetailed instances are created using a constructor from Ninetailed JavaScript SDK.

import { Ninetailed } from "@ninetailed/experience.js"

// Instantiation
const ninetailed = new Ninetailed(
    // Required
    ninetailedApiClientInstanceOrOptions,
    // Optional
    Options
)

Instantiation Options

import type { NinetailedPlugin } from "@ninetailed/experience.js"
import type { Ninetailed } from "@ninetailed/experience.js"
import type { NinetailedAPIClient, NinetailedApiClientOptions, NinetailedRequestContext, OnErrorHandler, OnLogHandler } from "@ninetailed/experience.js-shared"

type NinetailedApiClientInstanceOrOptions = NinetailedApiClient | NinetailedApiClientOptions;

type Options = {
    buildClientContext?: () => NinetailedRequestContext;
    componentViewTrackingThreshold?: number;
    locale?: Locale;
    onError?: OnErrorHandler;
    onInitProfileId?: OnInitProfileId;
    onLog?: OnLogHandler;
    plugins?: (NinetailedPlugin | NinetailedPlugin[])[];
    requestTimeout?: number;
    storageImpl?: Storage;
    url?: string;
    useSDKEvaluation?: boolean;
}

NinetailedApiClientInstanceOrOptions

Provide a created NinetailedApiClient instance (created using the Shared SDK @ninetailed/experience.js-shared), or supply parameters to create one.

Options

Specify optional configurations for the constructor.

Instance Methods and Properties

Last updated