FastBoot Express Middleware

4.1.2 · active · verified Wed Apr 22

This package provides an Express.js middleware for rendering Ember.js applications on the server side using FastBoot. It allows developers to integrate server-side rendering (SSR) capabilities into existing Express.js applications, primarily for SEO, improved initial page load performance, and serving non-JavaScript clients. The current stable version is 4.1.2. While there isn't a strict public release cadence, it typically follows major Ember/FastBoot updates and critical bug fixes, with `v3.0.0` introducing significant breaking changes. Its key differentiator is its direct integration with Express, offering maximum flexibility for users who prefer to manage their own server stack, in contrast to the more opinionated `FastBoot App Server`. It's designed for scenarios where an existing Express server needs to incorporate Ember FastBoot rendering without adopting a full FastBoot-specific server solution.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart sets up a basic Express server that serves static assets from an Ember app's `dist` directory and then uses `fastboot-express-middleware` to render Ember applications on all remaining routes, demonstrating a minimal SSR setup.

const express = require('express');
const fastbootMiddleware = require('fastboot-express-middleware');
const path = require('path');

// IMPORTANT: Replace '/path/to/your/ember-app/dist' with the actual path
// after running 'ember build'. For example, if your Express app is in the
// root and your Ember app is in a subdirectory named 'my-ember-app',
// this path might be path.join(__dirname, '..', 'my-ember-app', 'dist');
const distPath = process.env.EMBER_APP_DIST_PATH || path.join(__dirname, 'dist'); 

let app = express();

// Serve static assets from the Ember app's 'dist' folder
app.use(express.static(distPath));

// Apply the FastBoot middleware for all routes
app.get('/*', fastbootMiddleware(distPath));

const PORT = process.env.PORT || 3000;
app.listen(PORT, function () {
  console.log(`FastBoot app listening on port ${PORT}! Serving from: ${distPath}`);
});

view raw JSON →