Announcements · · 7 min read

Self Hosted XMTP

Self Hosted XMTP

Shane wrote about why we're changing course. I’m here to talk about what’s shipping, how to get started, and where the project goes from here.

tl;dr

Starting today, XMTP is a full messaging stack you can run yourself, and customize fully. It’s built for where messaging is heading: private conversations between people and agents, on infrastructure you control.

Who is XMTP for?

Until today, XMTP was mostly used by crypto apps that needed two wallets to talk to each other. Even if you only wanted to use XMTP for its privacy and security features, for developers outside the crypto space there was enough complexity and mental overhead around our approach to decentralization that it never made sense to adopt.

Starting today, XMTP is for everyone. If you need private and secure 1:1 or group messaging in your app, you should take a look at the new XMTP.

Agent to agent

If you want two or more agents to talk to each other, no matter what platform they're on, XMTP lets agents join your backend in seconds. Our Node.js SDK and CLI are battle-tested, and an agent can be up and running in under a minute. Agents can generate identities and join a network autonomously, and they don't need an open port on the public internet to receive messages.

Human to agent

If you want your users to talk to their Muse, Grokbot, Claude Code instance, or any other agent in real time from inside your app, XMTP might be a fit. The user copies a short prompt to their agent, and the agent can set themselves up and start chatting. We have SDKs for the browser, iOS, Android, and Node.js, plus a CLI.

Human to human

If you've been thinking about implementing Signal Protocol or MLS to add secure messaging to your app, you should definitely give XMTP a try first.

Implementing a secure messaging protocol - with all the features users require - is no small undertaking. XMTP is built on top of the MLS standard, and our libraries have been through multiple independent security audits and years of production use by Fortune 500 companies, startups, and thousands of developers, on just about every platform. It’s a full featured messaging stack that includes content types (replies, reactions, attachments), private group metadata, permissions and roles, and dozens of other features that are very difficult to implement privately and efficiently.

You will burn billions of tokens trying to re-create XMTP on top of Signal or MLS from scratch.

What's new

Moving from one global network to self-hosting let us make XMTP much more batteries-included. Everything gets easier when a network only has to meet one application's requirements, instead of balancing the needs of many node operators * many applications. That lets us ship features developers have asked for for years, which were simply too thorny to build on a global distributed network.

We added all of this while deleting close to 500,000 lines of code. Clients are simpler to work with, streaming is faster and more reliable, and common operations like adding members to a large group are 3x faster.

What changes

Today you pick an environment and the SDK connects to our network:

Client.create({ env: 'production' })

After the change, you point the SDK at a backend URL. Run your own, or connect to one hosted by someone else:

Client.create({ backendUrl: 'https://myapp.com' })

If your mobile app receives push notifications, read the push changes here. As part of version 8.0, we’ve unified the API surface across all of our SDKs, so if you are upgrading from a previous version you should hand the migration guide for your SDK over to a coding agent to migrate.

Running a backend

We have hosting guides for AWS ECS, Fly.io, Railway, and Kubernetes. If you'd rather not run one, you can connect to a backend another app hosts.

Migrating

  1. Upgrade to SDK 8.x on each platform.
  2. Deploy a backend (or pick one to connect to).
  3. Replace env with backendUrl in Client.create.
  4. Follow the upgrade guide for your specific SDK.
  5. If you run your own push server, switch to the built-in notifications and retire it
  6. If you run a backend to handle attachments, update your client code to use the built-in methods.

Clients start with a fresh local database the first time they connect to a self-hosted backend; there is no live message migration from the hosted network. Apps that already have messages stored can do a one-time import to a new SDK version by following this guide.

The hosted network keeps running until February 1, 2027, but don't wait. Migrating early means you're on the stack that's getting all of our attention.

Where this goes

Agents need a private way to talk

People are bringing their agents into every product they use. Agents built by different companies need to coordinate with each other and with the humans responsible for them. Today that mostly runs over Slack, email, Telegram, shared databases, and one-off APIs. Platform operators are willing to subsidize all this messaging volume so they can harvest training data for their own AI projects. None of it is private.

XMTP gives every person and agent its own identity and keys. The operator of the network can’t read messages or group metadata.

Instead of one network that we run, the plan is lots of them, run by the people building on them, all on the same open protocol.

Who maintains it

We’ve always said XMTP should be able to exist without XMTP Labs. Self-hosting is how we finish that job: you can run the whole stack, change it, and keep it running without needing anything from us.

XMTP has been open source since day 1. But in reality, we were “source available”. Anyone could open a PR - and we are grateful to everyone who has contributed - but the amount of context required to make larger contributions was too much. Complicated distributed systems problems on the backend, complicated client coordination problems on the front-end. It was very easy to make a change and break things for everyone else.

The self-hosted version of XMTP is a much friendlier place to make contributions. You can fork the repo, make changes for yourself, and test new features end-to-end. Because everyone is talking to their own backend, it’s straightforward to gate new features without risks to everyone else using the network.

Here’s how the project runs from here:

We have a long list of features that developers have been asking for, but were just too messy to release in a distributed and shared network. Here’s one example: we’ve long wanted a way for apps to be able to define custom fields on groups and users. That would let developers use the shared and permissioned group state in app-specific ways (linking outside accounts, maintaining scoreboards, customizing the look and feel of each group). Obviously useful feature.

We built support for this at the SDK level earlier this year but never opened it up for outside developers to contribute new fields to it. Why? Each field needs a globally unique Component ID, which means a registry where apps can claim one globally and other apps can read the definition. Doing that in a distributed and decentralized way gets complicated quickly, so we kept pushing the work off.

The feature wasn’t impossible before, but it is so much easier with the self-hosted network. I built it in a couple of days on the self-hosted foundation.

If you’ve been wanting to contribute to XMTP…this is the time.

We have release candidates for our 8.0 SDK publicly available for testing, and expect a stable and forwards-compatible release in the next few weeks.

— Nick

Read next