A typed TypeScript library for building JMAP clients. It handles session discovery, request building with type-safe invocation factories, response dispatching, file operations, and a plugin system for validation and transformation — so you can focus on your application instead of the protocol.
See the complete jmap-kit Documentation.
.well-known/jmap, session state tracking, staleness detectionmaxObjectsInGet, maxObjectsInSet, maxCallsInRequest, maxSizeRequest, and read-only accountsnpm install jmap-kit
yarn add jmap-kit
pnpm add jmap-kit
import { JMAPClient, EmailCapability, Mailbox } from "jmap-kit";
const transport = /* your HTTP transport (see Developer Guide) */;
const client = new JMAPClient(transport, { hostname: "api.example.com" });
client.registerCapabilities(EmailCapability);
await client.connect();
const accountId = client.primaryAccounts["urn:ietf:params:jmap:mail"];
// Query for the Inbox, then fetch it — in a single request
const query = Mailbox.request.query({
accountId,
filter: { role: "inbox" },
});
const get = Mailbox.request.get({
accountId,
ids: query.createReference("/ids"),
properties: ["id", "name", "role", "totalEmails", "unreadEmails"],
});
const request = client.createRequestBuilder().add(query).add(get);
const response = await request.send();
await response.methodResponses.dispatch({
"Mailbox/get": (invocation) => {
const mailboxes = invocation.getArgument("list");
console.log("Inbox:", mailboxes);
},
error: (invocation) => {
console.error("Error:", invocation.type);
},
});
await client.disconnect();
See the Developer Guide for comprehensive documentation covering session management, capabilities, invocations, request building, response handling, file operations, customisation, the plugin system, and creating custom capabilities.
git clone <repository-url>
cd jmap-kit
yarn install
| Command | Description |
|---|---|
yarn test |
Run tests in interactive watch mode (Vitest) |
yarn test --run |
Run all tests once (CI) |
yarn format:check |
Check Prettier formatting |
yarn lint |
Run ESLint (--fix to auto-fix) |
yarn typecheck |
Type-check without emitting files |
yarn build |
Compile TypeScript |
yarn bundle |
Build bundles with Rollup (for analysis, not shipped) |
yarn size-check |
Bundle and print file sizes |
yarn docs |
Generate API docs with TypeDoc |
Contributions are welcome! See the Contributing Guide for development setup, conventions, and PR guidelines.
jmap-kit currently implements the JMAP Core (RFC 8620), Mail (RFC 8621), and Blob Management (RFC 9404) specifications, plus the FastMail Masked Email extension. The following features are planned for future minor releases.
PushSubscription/get and PushSubscription/set methods for managing push notification subscriptionsgetEventSourceUrl() is already available)Support for capabilities defined in other published and draft JMAP specifications is planned, including:
Any of the above capabilities can be implemented as custom capabilities using the plugin system. Contributions are welcome!