Docs#

Docs below are for server-side rendering (sometimes referred to as pre-rendering or dynamic rendering). For taking screenshots or PDFs of webpages, see: /docs/api/screenshot-examples

Requirements for server-side rendering#

  1. you have a "single page app" with push state URLs (React, Angular, Ember, Vue, Preact etc...)
    • (the only true requirement is a JavaScript app that rewrites a container div as opposed to appending)
  2. a build or dist directory with your index.html and JavaScript files

Quick Start (1-step) Server-Side Rendering w/Node.js#

npm install -g prerendercloud-server
prerendercloud-server ~/path/to/build

note: Headless-Render-API.com was previously known as Prerender.cloud (rebranded 2022-05-01)

prerendercloud-server is a static, pushstate, Node.js server pre-configured with the official Headless-Render-API.com middleware. Pass it the path to your build/dist directory.

If testing from your dev machine: you will need a public IP or SSH remote port forwarding (we'll prompt you for this). Use ngrok if you don't have a public IP and/or don't want to configure SSH port forwarding.

Quick Start Server-side rendering on Fly.io#

See example code here: Server-side rendering on Fly.io (this Fly.io integration is how Headless-Render-API.com is hosted)

Quick Start (1-step) Server-Side Rendering Docker#

Read more about pre-rendering using our Docker image here

# run prerendercloud-server for the current directory
docker run \
  -e PRERENDER_TOKEN="my-secret-token" \
  -e DEBUG=prerendercloud \
  -p 9000:9000 \
  -v $(pwd):/wwwroot \
  prerendercloud/webserver

# run prerendercloud-server for an s3 bucket
docker run \
  -e AWS_ACCESS_KEY="my-aws-key" \
  -e AWS_SECRET_KEY="my-aws-secret" \
  -e PRERENDER_TOKEN="my-secret-token" \
  -e DEBUG=prerendercloud \
  -p 9000:9000 \
  prerendercloud/webserver s3://my-s3-bucket

Full guidance for our server-side rendering API#

  1. Read the requirements section above
  2. Read/skim How it works - and please note the "caveats" section near the bottom of that page to decide whether you should use this product
  3. Find your webserver in the list below and click the link to find configuration instructions
  4. Go through the checklist