Replicache downloads and stores data into a browser-local data store, where it can be accessed by the UI with zero network latency. It synchronizes this local storage continuously in the background with your server, and conflicts are resolved using a framework inspired by Git and CRDTs.
Replicache is best used for scenarios where you are creating an application from scratch. This is because to run, it requires an infrastructure that normal web apps don’t have. If you decide to use it for an existing application, you will have to refactor all of your business logic to incorporate the concepts of transactions and mutators. If you’re not already dealing with those, then your backend code might get affected.
Optimistic updates: The UI is always instantly responsive because all reads and writes go to local storage first. Actions like adding a new entry will appear instantly in the UI, and the UI in charge of listing the records and displaying new ones will be notified automatically.
Realtime updates: Users see each others’ changes live, as they happen, without refreshing or locking.
Offline-first support: Applications can go offline and sync up when they come back online.
Backend agnostic: As a client-side technology, Replicache works with most backend stacks.
Setup complexity: Whilst being backend-agnostic offers a great deal of flexibility, it also greatly adds to the build time, as you will need to construct per-client patches and opinionated client-server integration.
Less suited to use in existing applications: Replicache requires a very specific way of modeling your application state. That means that if you’re thinking about integrating Replicache into your existing application, you’ll probably have a hard time doing it, because you’ll have to refactor all your business logic.
Need to architect and build APIs from scratch for collaborative features: Replicache doesn’t come with ready-made APIs for collaborative features for things like chat, live cursors, avatar stacks or member locations - you need to architect and build from scratch.
Serializable transactions: For Replicache to work correctly, implementations of the interface must provide strict serializable transactions. This can reduce write throughput on the database and slow down transaction processing throughput. You also get an increased risk of deadlocks and aborted transactions which then need retrying.
Not built for global scale: There is no backend and therefore no SLA - you are reliant on the third-party SLAs you bring yourself.
Lack of integrations: No formally supported integrations for things like Lambdas or stream processors.
5 alternatives to Replicache
Replicache is just one of many solutions that you could choose for realtime synchronization when building multiplayer web applications.
Let’s look at five different solutions that show some different approaches to the problem of realtime sync. Each brings its own advantages and disadvantages and can be the right solution for your requirements to Replicache depending on your needs.
Unlike Replicache, Firebase is a backend-as-a-service (BaaS). That means it aims to replace the web server, data store, and backend code that otherwise you’d need to build and manage yourself. At its core, Firebase is a cloud storage solution that allows you to store and retrieve data related to your application and service, and it is used by many companies to build multiplayer web applications.
Firebase’s component - Firestore - is a cloud-hosted NoSQL database that works great for data storage and sync, providing an intuitive data model and fast queries. Firebase Authentication can be used to authenticate users, and you can use Firebase Cloud Messaging for native mobile notifications. But how well does Firebase stack up as a Replicache alternative?
Fast app set-up: Firebase offers functionality such as hosting, provisioning, DevOps management, data storage, and synchronization – which can help you cut off time and get your app to production faster, even without backend engineers.
Good developer experience: Firebase is known for the quality of technical documentation, as well as its SDKs for mobile platforms and popular web languages such as Java, Python, and Go. There’s also a large, global developer community who share advice, sample code, and other ways to help you become productive.
Free to get started: Most aspects of Firebase let you build a proof of concept or even a small production app without having to hand over any money.
Every event requires a database write: Firebase is all about the database. Anything that happens between the client and the backend must first become a database write. That way, even throwaway events become a burden on Firebase’s already limited capacity to handle concurrent connections and will increase your storage bill. Imagine having to write to the database every time your chat app needs to display a typing indicator.
Closed source platform: You cannot change code, even if what Firebase provides does not suit your app development needs.
Cannot support relational database structures: Firebase only provides a NoSQL database, which might not be the right fit if your data is relational. There are limitations to the flexibility of the query language, such as lack of join support
Vendor lock-in: Moving to another platform can be very hard if you're married to the Firebase ecosystem.
It’s harder to scale Firebase: Firestore can handle only 200,000 concurrent connections and, perhaps more limiting, only 1,000 writes per second. If your app needs to scale beyond those limits, then you lose much of the convenience that Firebase promised because you will have to shard your data across multiple instances. Sharding adds significant complexity to your app frontend. One alternative that Firebase offers is Cloud Firestore. That will handle up to around one million concurrent connections, but you’ll need to develop your own presence functionality manually, which again negates the benefits of using a backend-as-a-service.
Firebase can be expensive: Firebase gets you going quickly but you pay for that in higher usage fees. It’s also hard to spot when costs are running out of control. There are many stories of Firebase users receiving high bills as things got out of control. Take a look at How not to get a $30k bill from Firebase and We burnt $72K testing Firebase + Cloud Run and almost went bankrupt.
Hasura is an open source GraphQL engine that deploys realtime GraphQL APIs on any Postgres database, to query tables.
Database agnostic: The Hasura GraphQL Engine can connect to a wide range of databases, from Postgres to MySQL and Snowflake. Hasura will generate a full featured data API for you automatically, without needing to write handlers, schemas or resolvers.
Rapid development: With instant realtime APIs over Postgres, you can simply create tables and start querying the data in them over HTTP (queries and mutations) and WebSocket (subscriptions) - without the need to write any backend code.
Realtime GraphQL subscriptions: GraphQL's flexibility allows clients to request only the data they need. This reduces the over-fetching and under-fetching of data, which can be more efficient in certain scenarios.
Role-Based Access Control (RBAC): Hasura offers fine-grained access control with RBAC, allowing you to define who can access and modify specific data. This is critical for securing your collaborative applications and ensuring data privacy.
GraphQL specific: Hasura is tightly integrated with GraphQL, and if you prefer REST or other API technologies, you may find this integration limiting. Learning and implementing GraphQL may require additional time and resources.
Polling-based: While Hasura supports real time updates through subscriptions, it also relies on polling for some use cases, which may not be as efficient or immediate as some other realtime solutions, like WebSockets.
Scaling challenges: While Hasura is highly performant for many use cases, scaling realtime applications with a high volume of concurrent users can be challenging and may require additional infrastructure planning.
3. SWR Vercel
SWR is useful for working with remote data sources, such as APIs, and it's used in web applications built with React.
Optimistic updates: SWR supports optimistic updates, which is a significant advantage in collaborative applications. Users can see their actions take effect immediately, even before the data is confirmed on the server.
Seamless react integration: SWR is particularly well-suited to React applications. It provides a smooth integration experience with React components, enabling developers to easily manage and display data in the user interface.
Flexible data fetching: SWR offers flexibility in how you fetch data - making it adaptable to various data sources and APIs. You can use SWR to fetch data from REST APIs, GraphQL, or any other data source. This gives you versatility in your data-fetching approach.
Low developer overhead: SWR simplifies data-fetching and caching, reducing the developer overhead. Developers can focus on building application features and functionality without getting bogged down by complex data-fetching and caching logic.
Offline capabilities require additional setup: SWR primarily focuses on caching and revalidation, which may not cover offline capabilities out of the box. If your realtime collaborative app requires robust offline support, you'll need to implement additional solutions or libraries specifically designed for offline data synchronization.
Lack of realtime push: SWR uses polling-based strategies for data revalidation, which means all clients poll the latest data from backend, which can add additional load on the server and may not be as immediate as realtime WebSocket-based approaches. If your application demands instant data updates, you might need to implement WebSocket or similar technologies alongside SWR.
Not suitable for complex application state: In large realtime collaborative apps with complex state management, SWR may not be sufficient by itself. You might need to combine it with other state management solutions to handle state synchronization effectively.
No server-side implementation: SWR focuses on the client-side, while many realtime collaborative applications often require server-side considerations for synchronization and conflict resolution.
If you are looking for an open source solution to work through some collaborative ideas, then PartyKit is worth looking at. Not only is it free to use, but they also have a number of example apps to copy - ideal if you are wanting to develop a basic POC or benchmark other providers.
Open source: Partykit is free to use.
Local-first: Partykit can support local-first (offline) applications.
Platform-agnostic: PartyKit plays nicely with Vercel, Netlify, AWS, Cloudflare, fly.io, or wherever you host your app. No big rewrite needed.
Example apps: Broad selection of apps to gain inspiration from - from live cursors to AI chat apps.
Documentation: Limited information available on APIs.
Lack of support: Partykit support is only available through the community.
No SLAs or proprietary realtime infrastructure: Partykit doesn’t have its own realtime infrastructure. It runs on Cloudflare Workers, so it is unclear what happens if there are issues/ outages and who you should reach out to.
Limitations on concurrent user volumes: Partykit can only handle 100 concurrent users, and rooms can start struggling above volumes of 30-40 people.
Ably is a realtime infrastructure platform. Our realtime APIs and SDKs help you create multiplayer collaboration and a host of other realtime experiences ‘in-app’, without you having to build the underlying infrastructure. Currently, we offer two products that can be combined together:
Pub/Sub Channels: Offers the flexibility to build any realtime experience required.
Spaces: A purpose-built product for creating collaborative environments.
Ably is great for building a large scale, fully featured collaborative app with realtime sync throughout. Using Ably’s products Spaces and Pub/Sub Channels, you can unlock end-to-end realtime messaging throughout your app. While Spaces powers the features you need to enable synchronous collaboration for teams and manage their participant state, Pub/Sub Channels allows you to flexibly broadcast and sync app state changes between members, your backend, and any other pieces in your system design. With this combination of building blocks you can add any realtime feature you need, from avatar stacks, live cursors, member locations, live updates, component locking, annotations, to chat, comments, notifications, and more.
Why use Ably
Feature specific APIs: Spaces comes with purpose-built, realtime collaboration APIs for adding avatar stacks, member location, live cursors, and component locking. All APIs are optimized for top performance. For example, the live cursors API automatically batches pointer position events to avoid unnecessary streaming of messages whilst ensuring negligible latency. Pub/Sub Channels also provides APIs such as Presence or History that help developers deliver realtime features much faster.
High performance: Powered by our market-proven, realtime infrastructure that’s built for reliability at scale, backed by five nines SLAs and messaging guarantees.
<65 ms median latency.
Guaranteed message ordering and (exactly-once) delivery, even in unreliable network conditions.
Redundancy at regional and global levels.
Dynamic elasticity, built for scale.
A range of integrations: From Webhooks and React Hooks to serverless functions and streaming processors like Kafka, Ably has built front and backend integrations for a range of protocols, frameworks, databases and cloud services.
Which is the best collaboration solution for your use case?
Like everything in software, the answer is “it depends” - what realtime and collaborative features do you need? How do you envision users engaging with your application? Are you looking to save time upfront with a turn-key solution at the cost of flexibility later?
It's critical to try and answer these questions early on. Also, consider your appetite for sourcing and managing multiple vendors if you start with a solution that’s built just for collaboration but doesn’t easily support the implementation of other realtime features like chat, data broadcast, Pub/Sub, data sync, notifications, and more.
If you are looking for a solution that can support you now - as you integrate collaborative features - and as you scale, and introduce new features, you can try Ably for free (no credit card required) and make your own assessment.
Our free plan includes:
6M monthly messages
200 peak concurrent channels
200 peak concurrent connections
Cord alternatives: Top 5 competitors to consider in 2023
A round-up of the best alternatives to Cord for adding collaborative features - from avatar stacks to component locking - in-app.
Supabase alternatives: Competitors to consider in 2023
Discover the best alternatives to the Supabase backend as a service platform for realtime messaging and realtime sync in 2023.
5 great Pusher alternatives to consider
Read about 5 Pusher alternatives for developing functionality like live chat, realtime location tracking, activity feeds, and realtime charts and graphs.