Browser client
Use a short-lived bearer token to operate one connection.
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.
Typed operations
The browser client supports the connection state machine used by the embedded dialog: provider discovery and selection, authorization handoffs, plan review, change application, propagation checks, manual setup, cancellation, and retry.
You normally do not call these methods directly. domain0.connectDomain()
selects the valid operation for the current server 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.