Prember (Pre-Render Ember)
Prember is an Ember CLI addon designed to pre-render Ember applications into static HTML files during the build process, leveraging Ember FastBoot. This transforms a dynamic Ember app into a progressive static-site, enhancing initial page load performance and SEO for specified routes. The current stable version is 2.1.0, with minor updates released periodically and significant breaking changes typically reserved for major version bumps. Key differentiators include its 100% Ember-centric development experience, data agnosticism allowing any data source, instant navigation post-hydration, and full support for modern Ember features like Embroider. It addresses the common challenge of providing fast first-contentful-paint and SEO benefits without requiring a server-side rendering (SSR) runtime in the critical path at deployment.
Common errors
-
Error: Prember encountered an error during prerendering: No FastBoot manifest found
cause `ember-cli-fastboot` is not installed or configured correctly, or the Ember CLI build process failed to generate the necessary FastBoot assets.fixEnsure `ember-cli-fastboot` is installed (`npm install --save-dev ember-cli-fastboot`) and that your Ember app builds successfully with FastBoot enabled before attempting a Prember build. -
Build failed. The Broccoli Plugin 'Prember' failed with: Error: Cannot find module '...'
cause A module dependency required by your Ember app during FastBoot rendering is missing or not correctly bundled for the FastBoot environment.fixCheck your `package.json` for missing `dependencies` (not `devDependencies`), especially for modules used in `app/initializers` or `app/instance-initializers`. Ensure any Node.js-specific dependencies are correctly configured for FastBoot or mocked if they are browser-only. -
Node.js v14.x is not supported by prember@2.x.x
cause Attempting to run `prember` version 2.x.x (or higher) with an incompatible Node.js version.fixUpgrade your Node.js version to 16 or higher (`nvm install 16 && nvm use 16`) as `prember` v2.x.x requires Node.js >= 16. -
The 'prember' configuration option is missing 'urls'.
cause The `prember` configuration object in `ember-cli-build.js` does not specify any URLs to prerender.fixAdd an array of URLs to the `prember` configuration, e.g., `prember: { urls: ['/', '/my-page'] }`.
Warnings
- breaking Dropped support for Node.js versions prior to 16.
- breaking Dropped support for Node.js versions prior to 8.
- breaking Changes in how `config/fastboot.js` is applied.
- gotcha FastBoot instance recycling for long builds.
- gotcha URLs not prerendering or showing incorrect content.
- gotcha Web server configuration for prerendered files.
Install
-
npm install prember -
yarn add prember -
pnpm add prember
Imports
- Prember Configuration Object
import { prember } from 'prember';let app = new EmberApp(defaults, { prember: { urls: ['/', '/about'] } }); - prember.urls
prember: { urls: ['/', '/contact'] } - EmberApp Addon Options
let app = new EmberApp(defaults, { /* ... addon options ... */ });
Quickstart
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
let app = new EmberApp(defaults, {
// Configure prember to prerender specific URLs
prember: {
urls: [
'/', // The root path
'/about', // An example static page
'/products/1',// An example dynamic path (ensure it resolves correctly)
'/blog/latest',// Another example path
'/contact-us' // A more descriptive path
]
}
// Other Ember CLI build options can go here
});
// Use `app.toTree()` to return the Broccoli tree for your app
return app.toTree();
};
// To install the addons:
// npm install --save-dev ember-cli-fastboot prember
// To build the prerendered app:
// ember build --environment=production