Skip to content

Connect SDK

AlterConnect.create()

Construct an AlterConnect instance.

AlterConnect.create(config?) is the entry point. It returns a singleton-style instance that can be reused across multiple open() calls.

import AlterConnect from "@alter-ai/connect";
const alterConnect = AlterConnect.create({ debug: true });
AlterConnect.create(config?: AlterConnectConfig): AlterConnect
NameTypeDefaultDescription
config.debugbooleanfalseWhen true, the SDK logs lifecycle events to console.log under the [Alter Connect] prefix. Useful while integrating; leave off in production.
config.baseURLstringReserved. Not yet supported. Passing any value throws at construction time. Omit the field. See the note below.

An AlterConnect instance. See open(), events, and the type reference for AlterConnectConfig.

Calling create() once per application is the intended pattern. The instance keeps a single popup at a time; calling open() while a flow is already in progress is a no-op (the existing popup stays focused). Use isOpen() to check.

const alterConnect = AlterConnect.create();
button.addEventListener("click", () => {
fetchSessionToken().then((token) => alterConnect.open({ token, onSuccess }));
});

These are housekeeping methods returned by create(). The interactive method, open(), has its own page.

Close the popup if one is currently open. No-op on the mobile redirect flow (the page has already navigated away).

alterConnect.close();

Tear down the instance. Removes every registered event listener, clears state, and rejects subsequent method calls with an sdk_destroyed error. Use this on framework unmount.

alterConnect.destroy();

Returns true while the Connect UI is open.

if (alterConnect.isOpen()) {
// ...
}

Returns the installed SDK version string (e.g. "0.2.0").

alterConnect.getVersion();