Skip to content

JavaScript SDK

For build-tool projects, Lane.Chat ships typed npm packages that wrap the same window.laneChat widget contract as the script tag — with real TypeScript types, a programmatic loader, and SSR-safe framework bindings.

PackageWhat it isFor
@lanechat/jsTyped, SSR-safe core wrapper + loaderVanilla JS/TS, any framework
@lanechat/react<LaneChatProvider> + useLaneChat()React, Next.js, Remix
@lanechat/vueVue 3 plugin + useLaneChat()Vue 3, Nuxt 3

Not using a bundler? The script-tag install is still the simplest path — these packages call the same global under the hood.

Core — @lanechat/js

bash
npm install @lanechat/js
ts
import { LaneChat } from '@lanechat/js'

const lc = LaneChat.init({ appId: 'app_1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d' })
lc.on('open', () => console.log('panel opened'))
lc.identify({ email: '[email protected]', name: 'Jane Doe', plan: 'pro' })
lc.open()

React — @lanechat/react

bash
npm install @lanechat/react
tsx
'use client'
import { LaneChatProvider, useLaneChat } from '@lanechat/react'

function Root() {
  return (
    <LaneChatProvider appId="app_1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d">
      <App />
    </LaneChatProvider>
  )
}

function App() {
  const { open, identify } = useLaneChat()
  // after login: identify({ email, name })
  return <button onClick={open}>Need help?</button>
}

Vue — @lanechat/vue

bash
npm install @lanechat/vue
ts
import { createApp } from 'vue'
import { LaneChat } from '@lanechat/vue'

createApp(App).use(LaneChat, { appId: 'app_1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d' }).mount('#app')
vue
<script setup lang="ts">
import { useLaneChat } from '@lanechat/vue'
const { open, identify } = useLaneChat()
</script>

The API

All three packages expose the same surface as the widget's JavaScript API:

  • init(config) / provider / plugin — mount the widget. Idempotent; the loader is injected once.
  • open() / close() / toggle() / isOpen() / isMounted() — panel control and state.
  • show() / hide() — show or hide the floating launcher (the open panel is not affected by hide()).
  • unreadCount() — current unread badge count.
  • identify(traits) — set visitor identity and custom attributes in place (never remounts). Standard fields (email, name, phone, external_user_id) are promoted to the visitor profile; everything else is stored as a custom attribute visible to agents. See Identifying visitors.
  • updateTheme(theme) — runtime theme override.
  • on(event, cb) — subscribe; returns an unsubscribe function. Events: open, close, message_sent, message_received, unread_changed, session_loaded. See Events.
  • whenReady() — resolves with the raw widget API once loaded (null on SSR or load failure). Core package only.
  • destroy() — unmount (the loader script stays for a fast re-init).

Calls made before the widget script has loaded are buffered and replayed once it's ready — no need to await anything for the common path.

Config

appId is required. Optional: mode (floating | inline), container, customizations, allowedOrigins, loadNavScript, externalUserId, scriptUrl (override where the loader script is fetched from — it does not re-point the backend; Lane.Chat is a hosted service).

SSR

The React and Vue bindings are SSR-safe — the widget only mounts in the browser, so the packages are safe to import in Next.js / Nuxt server components. No window access happens during render.

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