Home

Awesome

ember-cli-prerender

An Ember CLI addon for prerendering Ember.js apps and generating sitemaps.

The problem

Applications that heavily use Javascript to render pages, like apps made with Ember.js or any other Javascript framework,

The solution

When a Javascript application is prerendered, the intial render on the client-side can happen before the Javascript files are loaded and run. Faster initial render improves the user experience and the search engine ranking.

Should I use this addon?

You should definitely use this addon if:

Features

Why not SSR? (server-side rendering)

These benefits can also be achieved with server-side rendering. FastBoot can be used to render Ember.js apps on the server-side, but it has these drawbacks:

This addon uses FastBoot when prerendering your app, but it uses it on buildtime instead of on runtime.

Is this production-ready?

This addon is being used in production in the following websites:

Are you using this addon in production as well? Edit README.md and add your site to this list!

Usage

Installation

  var app = new EmberApp(defaults, {
    'ember-cli-prerender': {
      sitemap: {

        /**
         * Your Ember app's internet address.
         * All relative paths in your sitemap will be prefixed with this.
         */
        rootUrl: 'https://mydummyapp.com/',

      },
    }
  });
{
  "scripts": {
    "build": "ember build",
    "postbuild": "ember prerender"
  }
}

Prerendering

npm run build

This will build your app, prerender it and generate sitemap files along with prerendered HTML files in your /dist directory.

Running the prerendered version

This is an optional step. If you would like to run the prerendered version locally, do the following:

{
  "scripts": {
    "start-prerendered": "static-server dist"
  }
}

Upgrading

If you're using an older version of this addon and want to upgrade to the newest version, follow these steps:

  1. npm install --save-dev ember-cli-prerender
  2. ember generate sitemap-utils (Choose NOT to overwrite your files, if you already have the utils.)
  3. ember generate sitemap xml (Only if you're using the XML sitemap)
  4. ember generate sitemap txt
  5. Run ember server and make sure your sitemap.txt works.

Optional settings for advanced usage

You most likely will not need to adjust any of the following settings.

SettingTypeDefaultDescription
input-dirStringdistChange it if your app does not get built in the default /dist directory.
output-dirStringdistBy default, the prerendered files are saved in your /dist folder. This option allows you to change that.
empty-output-dirBooleanfalseIf true, the prerendering script will clear the output directory before creating the prerendered files. Should be used in conjunction with output-dir.
max-simultaneous-url-fetchesNumber4We throttle requests to our local Fastboot server so it doesn't get overloaded with too many async requests.
root-urlStringYou can leave it blank if your app is located at the root-level on your domain. If your app is in a subfolder, this setting should match the rootUrl setting in your ember-cli-build.js.
sitemap-file-nameStringsitemapThe file name for the txt and xml sitemaps.
use-alternative-serverStringfalseIf you want to bypass using the prerender server and use one of your own

Example:

ember prerender --output-dir dist-static --empty-output-dir 1 --max-simultaneous-url-fetches 12

Contribution

As with every other open-source project, contributions are appreciated!

Todos

Installation

  1. git clone this repository
  2. npm install

Running

  1. npm start
  2. Visit the app at http://localhost:4200.

Testing

Building

Running the prerendered version

License

MIT