JavaScript API
The widget exposes one API object under two global names that are the same reference: window.laneChat === window.laneChatSDK. Any method works on either handle.
| Global | Status |
|---|---|
window.laneChat | Canonical name. Use this. |
window.laneChatSDK | Historic alias, permanently kept for backward compatibility. |
Methods
| Method | Returns | Description |
|---|---|---|
init() | widget instance | Mount the widget. Idempotent — repeat calls reuse the existing instance. |
destroy() | void | Unmount and clean up. Safe to init() again afterward. |
open() / openChat() | void | Open the chat panel. Emits open. openChat is an alias of open. |
close() | void | Close the chat panel. Emits close. |
toggle() | void | Toggle the panel. Emits open or close per the resulting state. |
isOpen() | boolean | Whether the panel is currently open. |
isMounted() | boolean | Whether the widget is mounted (useful before an SPA destroy()). |
updateTheme(themeConfig) | void | Update theme config at runtime. |
identify(traits) | void | Set or update visitor identity and custom attributes. See Identifying visitors. |
setFromData(data) | void | Alias of identify() (historic name), identical behavior. |
on(event, cb) | unsubscribe fn | Subscribe to a widget event. See Events. |
Lifecycle
js
// Mount (SPA / manual init)
window.laneChat.init()
// Is it up?
if (window.laneChat.isMounted()) {
// safe to operate on it
}
// Tear down
window.laneChat.destroy()init() is idempotent: repeat calls return the existing instance instead of mounting twice.
Opening and closing
js
window.laneChat.open() // open the panel
window.laneChat.close() // close it
window.laneChat.toggle() // flip based on current state
if (window.laneChat.isOpen()) {
// panel is currently open
}Theming at runtime
js
window.laneChat.updateTheme({
// theme config fields, applied live without a remount
})Identity
js
window.laneChat.identify({
email: '[email protected]',
name: 'Jane Doe',
plan: 'pro',
})See Identifying visitors for the full field and promotion contract.
Events
js
const off = window.laneChat.on('open', () => console.log('opened'))
off() // unsubscribeSee Events for the event list and semantics.
Additive by design
No existing method signature or behavior has changed across versions. laneChat, identify, and on are purely additive over the historic laneChatSDK / setFromData surface.