One-line host
createChatHost from @openmaxai/chat-openmax/react: takes the OpenMax options and re-exports the provider and list hook.
One-line host
@openmaxai/chat-openmax/react is the one-line entry point for OpenMax: createChatHost takes the config and builds a host; ChatProvider, ConversationScope, useChatSdkConversationList and the types ChatSdkHost, ChatSdkAdapterProfiles and ChatSdkProfileCardActions are re-exported unchanged from @openmaxai/chat-sdk/react and described on @openmaxai/chat-sdk · Host. When connecting to OpenMax, importing from this one entry point is enough. Status and an index of every export are on the Overview.
createChatHost
function createChatHost(config: OpenMaxOneLineConfig): ChatSdkHost;
function createChatHost(config: ChatSdkAdapterHostConfig): ChatSdkHost;
Two call forms: the first takes the OpenMax options, where OpenMaxOneLineConfig is OpenMaxChatConfig plus onUnauthorized?: never, onEvent?: never, cards?: never, profileCardActions?: never and attachments?: never, uploads?: never, resolveUrls?: never, resolveDownloadUrl?: never, and is not exported; the second takes ChatSdkAdapterHostConfig ({ adapter, ... }) and passes it unchanged to createChatHost from @openmaxai/chat-sdk/react.
Given the config, it builds the adapter with createOpenMaxAdapter and passes it, together with storage, instanceKey, locale, ports and markdown, to createChatHost from @openmaxai/chat-sdk/react for assembly.
- Synchronous. No request is sent and
getTokenis not called at construction. Until the current user is back,identity.currentUserId()is an empty string; when the data arrives,ChatProviderre-renders. - An invalid config throws
ChatSdkConfigErrorsynchronously; the rules are underOpenMaxChatConfig. - Does not take
onUnauthorized. The type rejects it (TypeScript does not compile); a JS caller that passes it getsChatSdkConfigErrorthrown synchronously when the host is built, with the fix in the message. When the credentials are gone, the failing call still throws aChatSdkRequestErrorwithkindunauthorized, realtime stops reconnecting, and the SDK shows "session expired" once throughattention.notify. For a callback, usecreateChatHost({ adapter: createOpenMaxAdapter(config), onUnauthorized })instead. This is a known gap, see Known gaps and version. - Does not take
onEvent, handled likeonUnauthorized: the type rejects it, and a JS caller that passes it getsChatSdkConfigErrorthrown synchronously when the host is built. To receive events, usecreateChatHost({ adapter: createOpenMaxAdapter(config), onEvent })instead. - Does not take
cards, handled likeonEvent: the type rejects it, and a JS caller that passes it getsChatSdkConfigErrorthrown synchronously when the host is built. A host built from the one-line form never draws business-card buttons; for card capabilities, use the{ adapter }form and pass the allowed business operations there:createChatHost({ adapter: createOpenMaxAdapter(config), cards: { isOperationAllowed } }). - Does not take
profileCardActions, handled likecards: a host built from the one-line form has no profile card; for profile cards, usecreateChatHost({ adapter: createOpenMaxAdapter(config), profileCardActions }). - Keys it does not recognise are ignored, not thrown. In development, when the host first mounts under
ChatProvider, each unrecognised key gets oneconsole.errorthat names it and says where it belongs:attachments,uploads,resolveUrlsandresolveDownloadUrlexplain that the OpenMax adapter wires attachments frombaseUrlandauthitself, and that changing them means the{ adapter }form with the adapter'suploadsreplaced; keys that only the{ adapter }form takes, such asrouteConversation, point to the{ adapter }form; port names point toports.<name>. It is reported once per host. A bundled production build prints nothing (the message text still ships in the bundle); source used without a bundler counts as development and reports.attachments,uploads,resolveUrlsandresolveDownloadUrlare typednever, so neither call form compiles with them; other unrecognised keys in the{ adapter }form are reported bycreateChatHostfrom@openmaxai/chat-sdk/react. - On the host it builds,
endpointUrl,authTokenandclientIdofinboundDeliveryare an empty string,undefinedand an empty string.
Code that connected to OpenMax with createChatHost from @openmaxai/chat-sdk/react only changes the import path; the config shape is the same. createChatHost from @openmaxai/chat-sdk/react takes only { adapter } and throws ChatSdkConfigError synchronously when given the OpenMax config.
