domain
Connect SDK

Browser client

Open one customer connection with short-lived browser access.

Create this client only after your server returns a connection ID and connection-scoped access token.

import { createDomain0Client } from 'domain0'

const client = createDomain0Client({
  baseUrl: '/api/domain0/',
  token: async () => getCurrentConnectionToken(),
})

The recommended baseUrl is a same-origin bridge in your application. That keeps browser requests first-party while the token remains bound to your exact origin. See the Next.js guide.

Usually, open the dialog

Pass this client to domain0.connectDomain(). The dialog selects the right provider and setup operation for the saved connection state.

const { connection } = await client.getConnection(connectionId)

if (connection.state === 'active') {
  console.log(`${connection.intent.domain} is connected`)
}

Use server state as truth

Closing a dialog does not delete the connection. Reopen it with the same ID and a fresh token to continue from its durable state.

On this page