@open-condo/bridge is the communication layer between a mini-app and the Condo client. It wraps the browser postMessage / message event pair in a typed, Promise-based API with automatic request tracking and timeouts.
Installation
Browser (CDN)
If you are not using a bundler you can load the UMD build directly:Quick start
API reference
bridge.send(method[, params[, timeout]])
Sends a method call to the Condo host and returns a Promise that resolves with the response data or rejects with an error.
Internally, send posts a message to window.parent with the structure { handler, params, type: 'condo-bridge', version } and correlates the response using an auto-generated requestId.
The bridge method name. Must be one of the supported
CondoWebApp* identifiers listed in the Methods section below.Method-specific parameters. See each method entry below for the exact shape.
Override the default timeout in milliseconds. Defaults to
1000 ms for most methods and 10000 ms for CondoWebAppRequestAuth.bridge.subscribe(listener)
Registers a listener that receives all incoming events and responses from the host. Use this when you need low-level access to the event stream, for example to react to host-initiated events such as CondoWebAppActionClickEvent.
A callback that receives every event object. Each event has a
type string and a data object.bridge.unsubscribe(listener)
Removes a previously registered listener. Always unsubscribe when the component or module that owns the listener is destroyed to avoid memory leaks.
The exact function reference that was passed to
bridge.subscribe.useEffect for automatic cleanup:
bridge.supports(method)
Returns true if the current runtime environment supports the given method. Use this for capability detection before calling a method that may not be available in all host environments.
The bridge method name to check.
bridge.supports checks against the statically known method list for the current environment. It does not make a network or postMessage call.Methods
Every method follows the same response naming convention:- Success response event:
<MethodName>Result - Error response event:
<MethodName>Error
CondoWebAppResizeWindow
Resizes the iframe in the host to the specified height. Use a ResizeObserver on document.body to keep the frame size in sync automatically.
Params
Target height of the iframe in pixels.
The height applied by the host.
CondoWebAppGetLaunchParams
Retrieves the launch context injected by the host when the mini-app was opened. Call this once on mount to identify the current user and their organisation.
Params
None.
Response
Condo user ID, or
null if the session is anonymous.Whether the user is a staff member or a resident.
The entity type the mini-app was launched in the context of.
The ID of the context entity.
BCP 47 locale string (e.g.
'ru', 'en').Stable identifier for the current device.
CondoWebAppShowNotification
Displays a toast notification in the host UI.
Params
Visual style of the notification.
Primary notification text.
Optional secondary text shown below the message.
true when the notification was displayed.CondoWebAppRedirect
Navigates the host application or opens a URL in a new tab.
Params
The destination URL.
'_self' navigates the host; '_blank' opens a new browser tab.true when the redirect was initiated.CondoWebAppRequestAuth
Asks the host to make an authenticated HTTP request on behalf of the mini-app. The host appends its own auth credentials and returns the response body. Useful for calling Condo APIs from the browser without exposing tokens to the mini-app origin.
This method has a 10-second default timeout because the host must perform a network request.
The URL the host should fetch.
A clonable response object.
CondoWebAppGetFragment
Returns the current URL fragment (hash) of the host page. Use this to read routing state the host may encode in the fragment.
Params
None.
Response
The current URL fragment, without the leading
#.CondoWebAppSetPageActions
Registers one or more action buttons that the host renders in a platform-specific location (for example the bottom action bar on web). The host returns a stable actionId for each action. Subscribe to CondoWebAppActionClickEvent to receive click callbacks.
Params
Array of action descriptors.
Stable IDs corresponding to each action in the order provided.
CondoWebAppShowModalWindow
Opens a modal window in the host that loads a URL (typically another page in the same mini-app).
Params
Modal header text.
URL to load inside the modal.
Modal size. Defaults to the host’s default size.
Initial height of the modal iframe in pixels.
Identifier for the modal, used with
CondoWebAppUpdateModalWindow and CondoWebAppCloseModalWindow.CondoWebAppUpdateModalWindow
Updates the title or size of an open modal window.
Params
The
modalId returned by CondoWebAppShowModalWindow.Fields to update. All fields are optional.
true if the modal was found and updated.CondoWebAppCloseModalWindow
Programmatically closes a modal opened by CondoWebAppShowModalWindow.
Params
The
modalId of the modal to close.The ID of the closed modal.
true if the modal was found and closed.CondoWebAppShowProgressBar
Displays a progress bar in the host UI for long-running background tasks.
Params
Primary label shown alongside the progress bar.
Optional secondary description.
An ID from your own task-tracking system, for correlation.
Identifier for the progress bar, used with
CondoWebAppUpdateProgressBar.CondoWebAppUpdateProgressBar
Updates the state of an active progress bar.
Params
The
barId returned by CondoWebAppShowProgressBar.Fields to update. All fields are optional.
true if the bar was found and updated.CondoWebAppGetActiveProgressBars
Retrieves all progress bars currently visible in the host for this mini-app.
Params
None.
Response
Array of active progress bar descriptors.
Incoming events
The host can push events to the mini-app at any time. Subscribe withbridge.subscribe to receive them.
CondoWebAppActionClickEvent
Fired when the user clicks an action button registered with CondoWebAppSetPageActions.
| Field | Type | Description |
|---|---|---|
actionId | string | ID of the action that was clicked. |
Error handling
Whenbridge.send rejects, the error object contains the following fields:
| Field | Type | Description |
|---|---|---|
errorType | 'client' | Always 'client' for errors generated by the bridge or the host. |
errorReason | string | Machine-readable reason code. |
errorCode | number | Numeric code corresponding to the reason. |
errorMessage | string | Human-readable description. |
errorReason | Code | Meaning |
|---|---|---|
ACCESS_DENIED | 0 | The mini-app does not have permission to call this method. |
UNKNOWN_ERROR | 1 | An unexpected error occurred in the host. |
UNKNOWN_METHOD | 2 | The method name is not recognised by the host. |
INVALID_PARAMETERS | 3 | Required parameters are missing or have the wrong type. |
HANDLER_ERROR | 4 | The host handler threw an error. |
TIMEOUT_REACHED | 5 | No response was received within the timeout period. |