Skip to content

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.

GlobalStatus
window.laneChatCanonical name. Use this.
window.laneChatSDKHistoric alias, permanently kept for backward compatibility.

Methods

MethodReturnsDescription
init()widget instanceMount the widget. Idempotent — repeat calls reuse the existing instance.
destroy()voidUnmount and clean up. Safe to init() again afterward.
open() / openChat()voidOpen the chat panel. Emits open. openChat is an alias of open.
close()voidClose the chat panel. Emits close.
toggle()voidToggle the panel. Emits open or close per the resulting state.
isOpen()booleanWhether the panel is currently open.
isMounted()booleanWhether the widget is mounted (useful before an SPA destroy()).
updateTheme(themeConfig)voidUpdate theme config at runtime.
identify(traits)voidSet or update visitor identity and custom attributes. See Identifying visitors.
setFromData(data)voidAlias of identify() (historic name), identical behavior.
on(event, cb)unsubscribe fnSubscribe 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() // unsubscribe

See 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.

Lane.Chat — AI customer support, multichannel CRM, and roleplay AI.