Skip to content

init ​

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

await init({
  publicKey: "pk_your_workspace_key",
  apiUrl: "https://api.justonecx.com",
  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.
frictionSignalsbooleantrueSet false to turn off the rage-click, dead-click and JS-error signals ($rage_click, $dead_click, $js_error). A dead click is only counted on something that looks clickable (pointer cursor, button or link role, onclick or a tab stop).
disableChatbooleanfalseDo not mount the chat bubble. Use it when you run the SDK for your own staff, so staff do not open chats in their own product.
excludePathsstring[]nonePaths where the SDK shows nothing at all. * is one path segment, ** any depth, for example ["/admin/**", "/preview"]. See Targeting.
disableTours, disableAnnouncements, disableSurveysbooleanfalseTurn one kind of content off for this init() call. The others keep working.
boardsUrlstringnext to the SDKWhere the lazily loaded justonecx-boards.global.js comes from. Set it when a strict CSP or a proxy needs a fixed location. See Embed.

Script tag equivalents ​

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

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