Library equivalent of Meteor’s realtime data layer?

At work we currently use Meteor with Vue, which means that we’re essentially using Meteor for its build tool, accounts and data layer; and we need realtime client-side updates when server-side data changes. My colleague is asking me what it would take to remove Meteor from the stack, not because we necessarily want to, but to justify Meteor by comparing what it gives us against the best available alternative. I know how we could replace Meteor as a build tool, and accounts-js is a freestanding library for adding authentication to any Node app (and says right in its docs that it’s a port of Meteor’s accounts system). So that just leaves the realtime data layer, which in my mind is the prime selling point of Meteor.

So if you’re building a Node app that needs realtime updates but you couldn’t use Meteor for some reason, and you didn’t want to roll your own realtime data layer, how would you implement the following:

  1. A websocket connection between client and server, where the client subscribes to something from the server (such as a database query, or a function, or an event callback); and

  2. A server-side publication of data for the client to consume, where

  3. When the data is updated server-side, the client is sent only the diff between what the client already has in memory and what the new state is; and

  4. (Bonus) the server-side can horizontally scale, because the data being watched for changes is in a database rather than in memory in the server process; and that database is monitored without polling, via something like Mongo oplog tailing (or MySQL binlog tailing, or Postgres NOTIFY, etc.).

My hunch is that there’s no single library or framework that does all of this, and that there’s no port of Meteor’s LiveQuery/overall data layer into its own library the way that accounts-js extracts the accounts management system. (Though if someone wants to attempt that, it seems like a great idea.) So even allowing that you’ll presumably need to cobble together several packages, what’s the closest you can come to replacing some or all of the above without writing it all yourself?

I think the only replacement is Apollo with pub/sub


@mitar I just discovered Could it be used to achieve what I’m looking for here? Do you have any examples of using it to stream reactive updates to a client, e.g. to keep Vuex or Redux in sync with database changes? Possibly with Apollo pub/sub as @coagmano suggests.

Yes, it could. But it is just a low level library. How you sync that to the client is up to you. You can use DDP, simply web socket directly, or anything else.