Introducing DDP

March 21, 2012 By Matt DeBergalis
Vote on Hacker News

Today we released Meteor 0.2.0. This is a major update that introduces DDP, the Distributed Data Protocol. DDP is a standard way to solve the biggest problem facing client-side JavaScript developers: querying a server-side database, sending the results down to the client, and then pushing changes to the client whenever anything changes in the database.

  • On the server, you define a realtime queries using Meteor.publish. You can pass an arbitrary JavaScript function to Meteor.publish, so you can publish data from any source: your database, IMAP, or the forklifts in your warehouse.

  • On the client, you call Meteor.subscribe to connect to a publication endpoint, receive the data, and listen for updates. The data is inserted directly into Meteor's client-side cache, so you can bind your HTML templates to it and they'll update automatically.

  • Meteor's DDP implementation handles the rest. It intelligently polls your database to pick up changes and push them down to the client. And it can simulate your model code on the client, so your users see their screens update immediately without waiting for the network.

DDP is a very simple protocol. It's just a codification of what you'd inevitably write yourself if you built this by hand. Because it's so simple, it's also general. DDP can work with any database, framework, or programming language, and it can work on servers, clients, and mobile devices. In fact, you can call Meteor.connect to connect to any DDP server -- such as a Meteor app written by someone else! -- and make realtime subscriptions to any data it's publishing.

Along with DDP, we added your top-requested feature: server-side methods. Clients can now call arbitrary JavaScript functions that you define on the server. Meteor uses reconnection and a replay cache to ensure that methods execute exactly once. (Never twice by accident, like in your hand-written XHR code.)

The features in this release have been promised in red boxes in the documentation since Meteor 0.0.1. We're very happy to have executed through so much of our roadmap and delivered them to you.

The Meteor blog

Thoughts on angular-meteor as a great MEAN Stack
Announcing our $20m Series B Funding
Meteor and a Galaxy of containers with Kubernetes
Two weeks with React + Meteor
Excited to be cool
How to give a conference talk on Meteor
Meteor reaches top ten on GitHub!
Meteor adding package summaries and scripting hooks