Skip to main content

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.

Do I always need init?

init is only necessary when installing via the npm commandbar package. If you install via the snippet, init is not needed.


Simplest initialization

import { init } from "commandbar";



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 CommandBar version

Enterprise tier.

import { init } from "commandbar";

init(YOUR_ORG_ID, { version: "0.5.45" });

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


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.



Additional options to use for initialization:

debugbooleanAllEnables additional logging
environmentstringEnterpriseBy 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.
versionstringEnterpriseDenotes the specific version of CommandBar to load.
configobjectEnterpriseA local json copy of your organizations config. See Self-hosting CommandBar - Config for more details.