JavaScript SDK
The Treliq JavaScript SDK is a lightweight (~10 KB gzipped) browser library that connects your application to the Treliq workflow engine. It handles user identification, event tracking, in-app content rendering, and offline event buffering.
What it does
- Identifies users — links a browser session to a stable user ID
- Tracks events — batched, retried on rate limit, queued offline
- Renders in-app content — banners, modals, popovers, and tooltips driven by your workflows
- Streams in real time — WebSocket connection for instant content delivery, with automatic polling fallback
- Reports actions — feeds user interactions back into running workflows
Reference
- Authentication — API keys and session tokens
- Configuration —
TreliqConfigoptions
API
The SDK exposes a single init() factory that returns a TreliqSDK instance with these methods:
| Method | Purpose |
|---|---|
identify(externalUserId, attributes?) | Link the session to a user |
track(eventName, properties?, options?) | Fire an event |
getInAppContent() | Manually fetch any pending in-app content |
reportAction(runId, actionId, result) | Report a user action back to a workflow |
reset() | Clear identity (call on logout) |
shutdown() | Flush queues and tear down listeners |
See Getting Started for a quick walk-through, or jump into any reference page on the left.
Authentication
How the Treliq SDK authenticates with the API using project API keys and session tokens.
Configuration
Every option accepted by init() and what each one controls.
Identify Users
Link a browser session to a stable user identity in your application.
Track Events
Send events from your application to trigger and feed Treliq workflows.
In-App Content
How banners, modals, popovers, and tooltips reach the user and how to control them.
Report Actions
Feed user interactions back into running workflows so they can advance to the next step.
Lifecycle: Reset & Shutdown
Cleanly end a user session with reset() and tear down the SDK with shutdown().
Errors & Debugging
Error types thrown by the SDK, the onError callback, and how to enable debug logging.
CDN / Script Tag
Drop the Treliq SDK into any HTML page with a single <script> tag.
Framework Integrations
Idiomatic patterns for using the Treliq SDK with React, Vue, Next.js, and other common frameworks.