Sliding Sync is a major overhaul of the MatrixDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/matrix-org/matrix-js-sdk/llms.txt
Use this file to discover all available pages before exploring further.
/sync endpoint designed to dramatically improve initial sync performance and reduce bandwidth. Instead of downloading every room’s state up front, the client requests a sliding window of rooms it currently needs and lets the server send updates incrementally.
Fast initial sync
Receive the first batch of rooms in milliseconds instead of waiting for the full room list.
Bandwidth efficient
Only fetch rooms currently visible in the UI. Expand the window as the user scrolls.
Server-side filtering
Filter by DM, encrypted, invited, space membership and more without client-side processing.
Extensible
First-class extension mechanism for E2EE device lists, account data, and push rules.
MSC4186 and server requirements
Sliding Sync (also known as Simplified Sliding Sync, MSC4186) is an evolution of the earlier MSC3575 proxy-based approach. Key differences:| MSC3575 (proxy) | MSC4186 (native) | |
|---|---|---|
| Infrastructure | Separate proxy server | Native homeserver support |
| Endpoint | Proxy URL | Homeserver URL |
| Matrix version | Pre-1.4 homeservers | Matrix 1.4+ (Synapse 1.114+) |
For homeservers that do not natively support MSC4186, the older MSC3575 proxy (
sliding-sync sidecar) can be deployed alongside the homeserver.Core classes
SlidingSync
SlidingSync is the low-level class that manages the /sync HTTP loop, list subscriptions, room subscriptions and extensions. It has no direct dependency on the high-level SDK model layer.
SlidingSyncSdk
SlidingSyncSdk bridges SlidingSync with the matrix-js-sdk model layer (rooms, room members, events). It implements the same SyncApi interface as the traditional sync implementation so the rest of the SDK does not need to know which sync method is in use.
Setting up Sliding Sync
import { SlidingSync } from "matrix-js-sdk";
// Define which room state fields you always want
const roomSubscriptionInfo: MSC3575RoomSubscription = {
required_state: [
["m.room.name", ""],
["m.room.avatar", ""],
["m.room.encryption", ""],
["m.room.member", "$ME"], // only our own membership
["m.room.create", ""],
],
timeline_limit: 20,
};
// Define the initial list of rooms to track
const lists = new Map<string, MSC3575List>([
["main", {
ranges: [[0, 19]], // first 20 rooms (0-indexed)
sort: ["by_notification_level", "by_recency"],
timeline_limit: 1,
required_state: [
["m.room.name", ""],
["m.room.avatar", ""],
],
filters: {},
}],
]);
const slidingSync = new SlidingSync(
"https://matrix.example.org", // proxyBaseUrl (or homeserver URL for MSC4186)
lists,
roomSubscriptionInfo,
client,
/*timeoutMS=*/ 30_000,
);
import { SlidingSyncSdk } from "matrix-js-sdk/lib/sliding-sync-sdk";
const slidingSyncSdk = new SlidingSyncSdk(
slidingSync,
client,
{ initialSyncLimit: 1 }, // ClientOpts
{}, // SyncApiOptions
);
// Start syncing
await slidingSyncSdk.sync();
Adjusting the room window
As the user scrolls through their room list you can expand the sliding window:Subscribing to individual rooms
Subscribe to a specific room (e.g. the currently open room) to receive full state and timeline updates:SlidingSyncEvent
Filtering rooms
TheMSC3575Filter interface controls which rooms appear in a list. All fields are optional and additive:
Extensions
Sliding Sync supports extensions that piggyback on the same HTTP request. The E2EE extension is registered automatically bySlidingSyncSdk when Rust crypto is enabled. You can implement your own:
Comparison with traditional sync
Traditional /sync | Sliding Sync | |
|---|---|---|
| Initial sync time | Minutes for large accounts | Sub-second for first window |
| Room state downloaded | All joined rooms | Only requested window |
| Filtering | Client-side only | Server-side before transmission |
| Hero computation | Client-side | Server-side (MSC4186) |
| Pagination position | next_batch token | Numeric pos |
| Extensions | No | Yes |