Skip to content

init ​

ts
import { init } from "@justonecx/sdk";

await init({
  publicKey: "pk_your_workspace_key",
  apiUrl: "https://api.justonecx.qd.je",
  trackRouteChanges: true,
});

init starts the SDK. It creates an anonymous visitor id (stored in the browser's localStorage), fetches the content published for this visitor, and shows it. Tours, announcements and surveys load independently, so a failure in one never blocks the others. It also mounts the chat bubble.

Options ​

OptionTypeDefaultDescription
publicKeystringnone (required)Workspace public key from Settings → Developers.
apiUrlstringhttp://localhost:8000Backend origin. Always set it on real sites. The SDK logs a warning if you do not.
trackRouteChangesbooleanfalseRe-run init() on every client-side navigation. Use it in single-page apps. Leave it off if you already call init() from your router.
disableChatbooleanfalseDo not mount the chat bubble. Use it when you run the SDK for your own staff, so staff do not open support chats in their own product.

Script tag equivalents ​

AttributeOption
data-public-keypublicKey
data-api-urlapiUrl
data-track-route-changes="true"trackRouteChanges: true

Calling init again ​

Calling init() again is safe. A tour or announcement already on screen is not fetched and shown a second time. This is what trackRouteChanges does for you.

Server-side rendering ​

Do not call init() on the server. It uses window and document. Importing the package on the server is safe.

JustOneCX