The `matrix-widget-api` package provides a JavaScript/TypeScript SDK for both Matrix widgets and the clients that host them, facilitating secure and standardized communication. It allows widgets to request capabilities (like sending messages or accessing state) and clients to drive widget behavior and respond to these requests. Currently at stable version 1.17.0, the library typically sees minor releases on a monthly or bi-monthly cadence, introducing new features, bug fixes, and sometimes breaking changes due to the evolving nature of the Matrix widget specification (which is not yet fully standardized). Its key differentiator is being the official SDK from Matrix.org, ensuring alignment with their reference implementations, though this also means it may be subject to changes as the underlying specification matures.
npm install matrix-widget-apiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize `WidgetApi` within a Matrix widget, request capabilities, register custom action handlers, start the communication, and send basic messages.
Review the changes in https://github.com/matrix-org/matrix-widget-api/pull/143 and update your `WidgetApi` and `WidgetDriver` implementations to match the new method signatures for delayed events.
If your widget claims compatibility with `UPDATE_STATE` via the API version, you must implement manual handling for state updates and not rely on automatic `send_event` actions from the client. Adjust your widget's `update_state` logic accordingly.
Migrate from `WidgetDriver.readRoomEvents` to `WidgetDriver.readTimelineEvents`. It is recommended to migrate all three deprecated APIs to their new solutions simultaneously for consistency.
Stay informed about new releases of `matrix-widget-api` and developments in the Matrix specification. Test your widgets thoroughly with target clients and be prepared for potential breaking changes as the spec evolves.
Upgrade to `matrix-widget-api` version 1.17.0 or newer to ensure `PostmessageTransport` instances properly clean up their event listeners upon being stopped.
Implement manual handling for state updates within your widget, as the responsibility for managing state events shifts to the widget when `UPDATE_STATE` is supported.
Migrate your client implementation to use `WidgetDriver.readTimelineEvents` and other new solutions introduced in v1.12.0 for reading room events and state. Ensure all three deprecated APIs are updated simultaneously.
Ensure your widget requests all necessary capabilities (e.g., `MatrixCapabilities.SendEvent`) early in its lifecycle using `api.requestCapability()` or `api.requestCapabilities()`. Verify the client implementation is correctly responding to and granting these requests.
Check the `src` attribute of your `<script>` tag to ensure the correct `unpkg.com` path and version (e.g., `https://unpkg.com/matrix-widget-api@1.17.0/dist/api.min.js`). Ensure your code accessing `mxwidgets` runs after the script has loaded, typically within a `DOMContentLoaded` listener.
No dependency data recorded yet.