← Back to Netflix/falcor

How to Deploy & Use Netflix/falcor

Falcor Deployment and Usage Guide

Prerequisites

  • Node.js (version 10 or higher)
  • npm (version 6 or higher)
  • Express.js (for server setup)
  • Git (for cloning the repository)

Installation

  1. Clone the repository:

    git clone https://github.com/Netflix/falcor.git
    cd falcor
    
  2. Install dependencies:

    npm install
    
  3. Install additional required packages for the example server:

    npm install falcor-router --save
    npm install express --save
    npm install falcor-express --save
    

Configuration

No specific environment variables or API keys are required for basic usage. However, you may need to configure your server settings in the index.js file:

// index.js
const falcorExpress = require("falcor-express");
const Router = require("falcor-router");
const express = require("express");
const app = express();

app.use(
    "/model.json",
    falcorExpress.dataSourceRoute(function (req, res) {
        // Router configuration goes here
        return new Router([
            {
                route: "greeting",
                get: () => ({ path: ["greeting"], value: "Hello World" }),
            },
        ]);
    })
);

app.listen(3000);

Build & Run

Development

  1. Start the server:

    node index.js
    
  2. Access the application:

    • Open your browser and navigate to http://localhost:3000/index.html
    • You should see "Hello World" retrieved from the server

Production

For production deployment, use the CDN version of Falcor:

<script src="https://cdn.jsdelivr.net/falcor/{VERSION}/falcor.browser.min.js"></script>

Deployment

Platform Suggestions

Based on the Node.js/Express stack, Falcor can be deployed on:

  1. Heroku

    • Create a Procfile with: web: node index.js
    • Deploy via Heroku CLI or GitHub integration
  2. AWS Elastic Beanstalk

    • Package the application and deploy as a Node.js environment
  3. DigitalOcean App Platform

    • Use the Node.js template and configure the run command
  4. Vercel/Netlify

    • Deploy the static frontend while keeping the Express server on a separate service

Deployment Steps

  1. Prepare the application:

    npm run dist
    
  2. Update CHANGELOG with new features/bug fixes

  3. Version bump:

    npm version patch
    
  4. Deploy to your chosen platform

Troubleshooting

Common Issues and Solutions

1. Port Already in Use

Issue: Port 3000 is already occupied Solution: Change the port in index.js:

app.listen(3001); // Change to available port

2. Missing Dependencies

Issue: Error: Cannot find module 'falcor-router' Solution: Ensure all dependencies are installed:

npm install falcor-router express falcor-express

3. CORS Issues

Issue: Cross-origin requests blocked Solution: Add CORS middleware to Express:

const cors = require('cors');
app.use(cors());

4. Build Errors

Issue: npm run dist fails Solution: Ensure you have the correct Node.js version and all dev dependencies:

npm install --dev

5. Version Compatibility

Issue: Breaking changes after upgrade Solution: Check the migration guides:

6. Static File Serving

Issue: Static files not loading Solution: Verify the static file path:

app.use(express.static(__dirname + "/"));

Additional Resources

  • Performance Models: Located in performance/models/legacy/_Cache.js
  • Core Implementation: lib/Model.js
  • Request Handling: lib/request/GetRequestV2.js
  • Documentation Generation: build/falcor-jsdoc-template/publish.js