Skip to main content
Version: v2

initialize

The initialize function sets up the Beyond Identity SDK and gives your app access to the rest of the SDK functions. The initialize function must be called first, before any other SDK functions.

Dependencies​

The initialize function requires the Beyond Identity SDK.

yarn add @beyondidentity/bi-sdk-js

or

npm install @beyondidentity/bi-sdk-js

Prerequisites​

Before making a call to initialize, you must import the SDK.

import { Embedded } from '@beyondidentity/bi-sdk-js';

Parameters​

ParameterTypeDescription
configConfig

An optional configuration object.

↳ allowedDomains

string[]

An optional list of allowed domains.

↳ logger

Log

An optional interface for logging with method write(...data: any[]): void;.

Returns​

On success, returns a Promise that resolves to an instance of the Embedded class. Call the other SDK functions on this instance.

Examples​

Example: initialize the SDK before calling its functions​

// --- Initialize with required arguments
try {
const embedded = await Embedded.initialize();
console.log("Initialization successful", embedded);
} catch (error) {
console.error("Initialization failed:", error);
}

// --- Initialize with required and optional arguments
const config = {
allowedDomains: ["example.com", "another-example.com"],
logger: function (logType, message) {
console.log(`[${logType}] ${message}`);
},
};

try {
const embedded = await Embedded.initialize(config);
console.log("Initialization successful", embedded);
} catch (error) {
console.error("Initialization failed:", error);
}