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 });Signature
Section titled “Signature”AlterConnect.create(config?: AlterConnectConfig): AlterConnectParameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
config.debug | boolean | false | When true, the SDK logs lifecycle events to console.log under the [Alter Connect] prefix. Useful while integrating; leave off in production. |
config.baseURL | string | — | Reserved. Not yet supported. Passing any value throws at construction time. Omit the field. See the note below. |
Returns
Section titled “Returns”An AlterConnect instance. See open(), events, and the type reference for AlterConnectConfig.
Reusing the instance
Section titled “Reusing the instance”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 }));});Instance lifecycle methods
Section titled “Instance lifecycle methods”These are housekeeping methods returned by create(). The interactive method, open(), has its own page.
close()
Section titled “close()”Close the popup if one is currently open. No-op on the mobile redirect flow (the page has already navigated away).
alterConnect.close();destroy()
Section titled “destroy()”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();isOpen()
Section titled “isOpen()”Returns true while the Connect UI is open.
if (alterConnect.isOpen()) { // ...}getVersion()
Section titled “getVersion()”Returns the installed SDK version string (e.g. "0.2.0").
alterConnect.getVersion();