init(org, opts?)
Initializes CommandBar and injects the scripts required to load it into the head
of the document. After calling this function it will be possible to access window.CommandBar and call the SDK methods, even if the scripts have not finished loading yet. However, CommandBar will not be available to the end-user, until boot
is called.
init
?init
is only necessary when installing via the npm commandbar package. If you install via the snippet, init
is not needed.
Examples
Simplest initialization
import { init } from "commandbar";
init(YOUR_ORG_ID);
Advanced
Enable debug logging
import { init } from "commandbar";
init(YOUR_ORG_ID, { debug: true });
Set a specific release environment
Enterprise tier. See Releases.
import { init } from "commandbar";
init(YOUR_ORG_ID, { environment: "qa" });
Pin a specific Release version config
Enterprise tier.
import { init } from "commandbar";
init(YOUR_ORG_ID, { version: "v13" });
Load a local copy of your CommandBar config
Enterprise tier. Self-hosting CommandBar - Config for more details.
import { init } from "commandbar";
init(YOUR_ORG_ID, {config: {...}})
Function parameters
org Required
string
UUID corresponding to your organization, which can be found in the Dashboard in the left sidenav, click your org name at the bottom and copy Org ID.
opts
object
Additional options to use for initialization:
Property | Type | Tier | Description |
---|---|---|---|
debug | boolean | All | Enables additional logging |
environment | string | Enterprise | By default, environment loaded is latest , which always contains the latest version of CommandBar. When using Releases, you can specify two additional environments ("qa", "prod"). These can be any string literal, and you'll provide them to the CommandBar team to update. See Releases for more details. |
version | string | Enterprise | Denotes the specific version of CommandBar to load. |
config | object | Enterprise | A local json copy of your organizations config. See Self-hosting CommandBar - Config for more details. |