LibraryActive

Replicache

Replicache is a JavaScript library for building offline-first applications with real-time sync.

Open source page

Field note

What it does

Replicache is a JavaScript library that enables offline-first applications by providing persistent data storage in the browser using IndexedDB. It requires a name for the Replicache instance, which determines shared storage among instances. Typically, the logged-in user's ID is used as the name to separate user data.

Capabilities

Available capabilities

Tags

Tags

Ways to use it

Ways to use it

sdk

JavaScript / Not filed

sdk

JavaScript / Not filed

sdk

JavaScript / Not filed

sdk

JavaScript / https://doc.replicache.dev/

Product features

Product features

Base64 encoding

Store binary data as base64 strings in Replicache.

Chat App Example

The guide walks through building a complete chat app.

Client Groups

Clients that share data locally are grouped, allowing changes to be visible across clients even offline.

Conflict Resolution

Changes are merged in a principled fashion, ensuring predictable outcomes.

Constructor Requires Name

The Replicache constructor requires a name parameter.

Content-addressed data

Use a hash of the content as the key for immutable large data.

Custom Backend

Supports building your own backend for the app.

Efficient Rendering

Only calls query functions when accessed keys change and onData when result changes.

External blob storage

Store blobs outside Replicache, e.g., in S3, to exceed size limits.

Global Version Strategy

For simple apps with low concurrency and all data synced to all users; limited to ~50 pushes/second.

IndexedDB Storage

Replicache stores data persistently in the browser using IndexedDB.

IndexedDB Sync

Detects when IndexedDB is removed and throws IDBNotFoundError.

Local Storage Persistence

Replicache loads data from local storage at startup for persistence.

Mutators

Functions that run optimistically on the client and authoritatively on the server.

Offline Support

Clients can compute incorrect results while offline, then snap to server truth after sync.

Offline Sync

Synchronizes data between client and server for offline-first apps.

Optimistic Revert

Replicache reverts optimistic changes when the authoritative server result is known.

Optimistic Updates

Supports local optimistic changes that are reflected immediately and synced later.

Per-Space Version Strategy

Partitions data into spaces; all users in a space sync that space entirely.

Poke

Server can send a poke to trigger an immediate pull for realtime updates.

Poke Channel

Optional realtime updates via server-sent events.

Push and Pull

Syncs changes by pushing local mutations and pulling server state.

Push and Pull Sync

Replicache pushes local changes to the server and pulls server changes periodically.

Reset Strategy

Simple strategy for small data or infrequent changes; retransmits entire client view on each pull.

Row Version Strategy

Most flexible and powerful; supports fine-grained read auth and partial sync, but hardest to implement.

Shared Storage by Name

Instances with the same name share storage.

User ID as Name

Typically, use the logged-in user's ID as the name to keep storage separate.