Falcor
A JavaScript library for efficient data fetching.
Roadmap
Issues we're tracking as part of our roadmap are tagged with the roadmap label. They are split into enhancement, stability, performance, tooling, infrastructure and documentation categories, with near, medium and longer term labels to convey a broader sense of the order in which we plan to approach them.
Getting Started
You can check out a working example server for Netflix-like application right now. Alternately, you
can go through this barebones tutorial in which we use the Falcor Router to
create a Virtual JSON resource. In this tutorial we will use Falcor's express
middleware to serve the Virtual JSON resource on an application server at the
URL /model.json
. We will also host a static web page on the same server which
retrieves data from the Virtual JSON resource.
Creating a Virtual JSON Resource
In this example we will use the falcor Router to build a Virtual JSON resource
on an app server and host it at /model.json
. The JSON resource will contain
the following contents:
Normally, Routers retrieve the data for their Virtual JSON resource from backend
datastores or other web services on-demand. However, in this simple tutorial, the
Router will simply return static data for a single key.
First we create a folder for our application server.
Now we install the falcor Router.
Then install express and falcor-express. Support for restify is also available,
as is support for hapi via a third-party
implementation.
Now we create an index.js
file with the following contents:
Now we run the server, which will listen on port 3000
for requests for
/model.json
.
Retrieving Data from the Virtual JSON resource
Now that we've built a simple virtual JSON document with a single read-only key
greeting
, we will create a test web page and retrieve this key from the
server.
Create an index.html
file with the following contents:
Now visit http://localhost:3000/index.html
and you should see the message
retrieved from the server:
Hello World