Appearance
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
| 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. |
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 support chats in their own product. |
Script tag equivalents
| Attribute | Option |
|---|---|
data-public-key | publicKey |
data-api-url | apiUrl |
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.