The JavaScript SDK is a small Rechat.Sdk class for working with Rechat from your own
code: capturing leads, tracking visitor activity, and reading listings, the agent
roster, and testimonials.
const sdk = new Rechat.Sdk()
| Namespace | What it does |
|---|---|
sdk.Leads |
Lead capture and HTML-form binding |
sdk.Leads.Tracker |
Visitor activity tracking (viewed a listing, searched, signed up, …) |
sdk.Listings |
Listing search and counts |
sdk.Agents |
The brand's agent roster |
sdk.Testimonials |
The brand's testimonials |
All settings are optional:
const sdk = new Rechat.Sdk({
sandbox: false,
api_url: 'https://api.rechat.com',
tracker: { cookie: { name: 'rechat-sdk-tracker' } },
offline_sync: { max_queue_size: 500 },
})
| Setting | Default | Description |
|---|---|---|
sandbox |
false |
true targets the sandbox API instead of production |
api_url |
"https://api.rechat.com" |
Full API base URL override (wins over sandbox) |
tracker |
on | Lead Tracker options, or false to disable tracking |
offline_sync |
on | Offline queue options (below), or false to disable |
Some namespaces route their requests through a Rechat portal — a per-domain brokerage configuration that resolves the brand automatically:
sdk.Agents and sdk.Testimonials are portal-only. On a hostname with no
registered portal their methods reject.sdk.Listings prefers the portal but falls back to the public API when no portal
is registered for the current hostname.sdk.Leads doesn't use portals at all — lead capture works on any site.Portal discovery starts as soon as the SDK is constructed. To know whether the current site is a portal:
sdk.Ready
.then(portal => console.log('Portal site:', portal.id))
.catch(() => console.log('Not a portal site'))
Lead capture and tracking calls made while the browser is offline are queued in
localStorage and re-sent automatically when the connection comes back. A queued
capture resolves with { queued: true } instead of the created lead.
const sdk = new Rechat.Sdk({
offline_sync: {
storage: window.sessionStorage, // any Storage-like object; default localStorage
max_queue_size: 500, // default 500; further requests are rejected
on_sync_complete: () => console.log('Offline queue flushed'),
},
})
Set offline_sync: false to disable the queue — offline requests then reject like any
failed network call.