matrix-appservice is a Node.js framework designed to facilitate the creation of Matrix application services. It provides a web framework agnostic way to quickly set up performant services that can interact with a Matrix homeserver. The current stable version is 4.0.1, released in April 2026. The project maintains a roughly annual major release cadence, primarily driven by updates to Node.js version support and occasional API adjustments. It differentiates itself from more fully-featured SDKs like `matrix-appservice-bridge` by offering a more minimalist, flexible foundation for building application services, focusing on core communication patterns rather than higher-level bridging abstractions.
npm install matrix-appserviceVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to generate a `registration.yaml` file for your application service and then how to initialize and run the `AppService` instance to listen for incoming Matrix events and handle user/alias queries. It includes an example of using `AppserviceHttpError` for error signaling and notes on optional TLS setup.
Upgrade your Node.js runtime to meet the minimum version specified by the package's `engines` field (currently `>=24` for v4.0.1) or downgrade the `matrix-appservice` package to a version compatible with your Node.js runtime.
Update any custom application service logic that directly interacted with these legacy endpoints to use the Matrix spec-defined paths instead. The framework itself should handle most of this transparently, but custom integrations might be affected.
Prefer `import { Name } from 'matrix-appservice'` over `const Name = require('matrix-appservice')` for consistency and to leverage TypeScript type definitions and modern tooling. Ensure your `package.json` specifies `"type": "module"` or use a `.mjs` extension for your application service entry point.Set `MATRIX_AS_TLS_KEY=/path/to/your/key.pem` and `MATRIX_AS_TLS_CERT=/path/to/your/cert.pem` in your environment before starting the application service. Ensure the files are readable by the Node.js process.
When an error condition occurs within `onUserQuery` or `onAliasQuery` that should propagate as a specific HTTP error to the homeserver (e.g., user not found, forbidden), throw an `AppserviceHttpError` instance, providing a Matrix error object and an HTTP status code, like `throw new AppserviceHttpError({ errcode: 'M_FORBIDDEN', error: 'User creation forbidden.' }, 403);`.If using CommonJS, ensure you destructure it: `const { AppServiceRegistration } = require('matrix-appservice');`. If using ES Modules, use `import { AppServiceRegistration } from 'matrix-appservice';`.Ensure only one instance of the application service is running. If necessary, change the port it listens on in `as.listen(port)` and update the `appServiceUrl` in your `registration.yaml` accordingly.
Upgrade your Node.js installation to a version that satisfies the `engines.node` requirement in the `matrix-appservice` package's `package.json` (currently `>=24` for v4.0.1). Use a Node.js version manager like `nvm` or `volta` to easily switch versions.
Verify that your `registration.yaml` file is correctly uploaded to the homeserver and that its `url` and `as_token` match the `appServiceUrl` and `appServiceToken` you configured in your `AppService` instance. Check homeserver logs for more specific errors related to the app service.
No dependency data recorded yet.