gitmyhub

falcor

JavaScript ★ 11k updated 9mo ago

A JavaScript library for efficient data fetching

Falcor is a JavaScript library from Netflix that lets your web app request data from a single virtual JSON document instead of many API endpoints, automatically caching results and fetching only what is missing.

JavaScriptNode.jssetup: moderatecomplexity 3/5

Falcor is a JavaScript library built by Netflix that gives your web application a single, unified place to ask for data. Instead of making many separate requests to different server endpoints, your app talks to one virtual JSON document and asks for exactly the pieces it needs. Falcor figures out how to fetch only what is missing, caches what it already has, and returns everything as if it all came from one clean object.

On the server side, you define a Router that maps paths in that virtual JSON document to real data sources, whether those are databases, other APIs, or anything else. The Router responds to requests by filling in the requested paths with actual values. Falcor ships with middleware for popular Node.js web frameworks so you can serve this virtual document at a URL like /model.json without writing a lot of boilerplate.

On the client side, your JavaScript code creates a Model object that points to the server URL. You then call get with a list of paths you want, and the Model returns a plain JavaScript object with those values filled in. It handles caching automatically, so if your app asks for the same data twice, the second request never leaves the browser.

The current stable release is version 2.0, with migration guides available for anyone upgrading from older versions. The project is maintained by Netflix and accepts community contributions through pull requests, with a public roadmap tracked through labeled GitHub issues covering enhancements, stability, performance, tooling, infrastructure, and documentation.

Falcor is best suited for JavaScript developers building data-heavy applications who want to reduce the number of round trips between client and server. It requires familiarity with Node.js and a basic understanding of how web servers and APIs work, though the getting-started tutorial walks through setting up a minimal working example from scratch.

Where it fits