Skip to main content

Hexa Background Client Service (core)

Classes

HexaBackgroundClient

Background-context HexaClient. Extends the base with tab-targeted messaging and broadcast.

import { HexaBackgroundClient } from '@hexajs-dev/core';
class HexaBackgroundClient { ... }

Methods

broadcast()

Broadcast a fire-and-forget message to all tabs.

broadcast<TPayload>(target: `${namespace}:${api}`, payload?: TPayload): Promise<void>

sendMessage()

Send a message and await a response. Content → background uses runtime.sendMessage. Background → content requires a tabId — use BackgroundHexaClient.sendToTab().

sendMessage<TPayload, TResponse>(target: `${namespace}:${api}`, payload?: TPayload): Promise<TResponse>

sendToTab()

Send a message and await a response. Content → background uses runtime.sendMessage. Background → content requires a tabId — use BackgroundHexaClient.sendToTab().

sendToTab<TPayload, TResponse>(tabId: number, target: `${namespace}:${api}`, payload?: TPayload): Promise<TResponse>