Appearance
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
| Option | Type | Default | Description |
|---|---|---|---|
publicKey | string | none (required) | Workspace public key from Settings → Developers. |
apiUrl | string | http://localhost:8000 | Backend origin. Always set it on real sites. The SDK logs a warning if you do not. |
trackRouteChanges | boolean | false | Re-run init() on every client-side navigation. Use it in single-page apps. Leave it off if you already call init() from your router. |
frictionSignals | boolean | true | Set 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). |
disableChat | boolean | false | Do 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. |
excludePaths | string[] | none | Paths where the SDK shows nothing at all. * is one path segment, ** any depth, for example ["/admin/**", "/preview"]. See Targeting. |
disableTours, disableAnnouncements, disableSurveys | boolean | false | Turn one kind of content off for this init() call. The others keep working. |
boardsUrl | string | next to the SDK | Where 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
| Attribute | Option |
|---|---|
data-public-key | publicKey |
data-api-url | apiUrl |
data-track-route-changes="true" | trackRouteChanges: true |
data-boards-url | boardsUrl |
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.