Skip to content

Instantly share code, notes, and snippets.

@jbutko
Last active May 2, 2019 14:30
Show Gist options
  • Save jbutko/632a1ac69d0cff4a15e656bf870b45d8 to your computer and use it in GitHub Desktop.
Save jbutko/632a1ac69d0cff4a15e656bf870b45d8 to your computer and use it in GitHub Desktop.
Nginx Prerender.io setup

1. configure nginx config (or virtual host config) which is serving your local react (or any js framework) app via this official prerender.io nginx config:

https://gist.github.com/thoop/8165802

2. install local prerender server following this tutorial

https://prerender.io/documentation/test-it

Note: if the server won't run because of missing chrome installed, then install it. On ubuntu follow this instructions: https://www.ubuntuupdates.org/ppa/google_chrome?dist=stable -> the final command is sudo apt-get install google-chrome-stable

3. start your local prerender.io server:

PORT=3009 node server.js (or use pm2 with json config file)

4. change public prerender.io server for your local one, via editing of nginx conf of your app and replace this line:

set $prerender "service.prerender.io";

to this:

set $prerender "127.0.0.1:3009";

5. [BONUS] if you are using css-in-js library (emotion, styled-components) you need to turn off speedy mode to have css rendered. Example of the setup for emotion here:

https://github.com/emotion-js/emotion/blob/master/docs/ssr.md#puppeteer

prerender.io documentation: https://prerender.io/documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment