{"id":17233657,"url":"https://github.com/piuccio/prerender-chrome-headless","last_synced_at":"2025-04-14T02:32:13.645Z","repository":{"id":51919916,"uuid":"95399403","full_name":"piuccio/prerender-chrome-headless","owner":"piuccio","description":"Pre-render single page applications to static HTML file","archived":false,"fork":false,"pushed_at":"2021-05-09T02:32:56.000Z","size":627,"stargazers_count":33,"open_issues_count":9,"forks_count":3,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-05-29T22:43:11.561Z","etag":null,"topics":["chrome-headless","prerender","single-page-application","webpack-plugin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/piuccio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-26T02:11:52.000Z","updated_at":"2024-01-29T06:27:59.000Z","dependencies_parsed_at":"2022-08-29T05:11:29.303Z","dependency_job_id":null,"html_url":"https://github.com/piuccio/prerender-chrome-headless","commit_stats":null,"previous_names":["en-japan-air/prerender-chrome-headless"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piuccio%2Fprerender-chrome-headless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piuccio%2Fprerender-chrome-headless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piuccio%2Fprerender-chrome-headless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piuccio%2Fprerender-chrome-headless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piuccio","download_url":"https://codeload.github.com/piuccio/prerender-chrome-headless/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223612756,"owners_count":17173639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome-headless","prerender","single-page-application","webpack-plugin"],"created_at":"2024-10-15T05:25:32.600Z","updated_at":"2024-11-08T01:27:17.611Z","avatar_url":"https://github.com/piuccio.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/en-japan-air/prerender-chrome-headless.svg?branch=master)](https://travis-ci.org/en-japan-air/prerender-chrome-headless)\n\n# Generate static pages from single page applications\n\nFew tool out there allow you to pre-render web applications to static pages either using webpack or fake browser.\n\nThis package uses [headless chrome](https://developers.google.com/web/updates/2017/04/headless-chrome) for a more accurate pre-rendering in an actual browser.\n\nAs of version `2.0.0` this package internally uses [puppeteer](https://github.com/GoogleChrome/puppeteer).\n\n## Usage\n\n```js\nconst render = require('prerender-chrome-headless');\nconst fs = require('fs');\n\nrender('https://google.com').then((html) =\u003e {\n  fs.writeFileSync('/tmp/rendered-page.html', html);\n});\n```\n\n### Chrome flags\n\nBy default this package runs chrome with `--disable-gpu` and `--headless` you can pass additional [flags](http://peter.sh/experiments/chromium-command-line-switches/) calling\n\n```js\nrender(url, ['--disable-http2'])\n```\n\n### Options\n\n```js\nrender(url, {\n  delayLaunch: 0, // milliseconds\n  delayPageLoad: 0, // milliseconds\n  chromeFlags: [], // list of flags\n  puppeteerOptions: {}, // puppeteer launch options\n  onPageError() {} // callback\n});\n```\n\nThe second parameter of `render` function can either be an array of chrome flags or an object with\n\n* `delayLaunch` Wait to launch Chrome browser, in case you need more time to set up the server\n* `delayPageLoad` Wait after the page load event for your JS to run\n* `chromeFlags` List of chrome flags\n* `puppeteerOptions` Options for puppeteer launch as [documented at puppeteer](https://github.com/GoogleChrome/puppeteer/blob/v1.13.0/docs/api.md#puppeteerlaunchoptions). \nNote, you can specify chromeFlags here as well but if you specified chromeFlags then that takes precedence over `args` defined in `puppeteerOptions`.\n* `onPageError` Function called when an uncaught exception happens within the page. You can use this function for \ninstance to fail your build if error happens during the generation of the page\n\n\n## Continuous integration\n\nThe package works on any machine with Chrome installed. Most CI environments allows you to install external packages.\n\n### Travis\n\nHere is what you have to do to get Chrome headless working on Travis\n\n```yml\n# The default at the time of writing this blog post is Ubuntu `precise`\n# Chrome addon is only available on trusty+ or OSX\ndist: trusty\n\n# This will install Chrome stable (which already supports headless)\naddons:\n  chrome: stable\n\nbefore_install:\n  # Needed by `chrome-launcher`\n  - export LIGHTHOUSE_CHROMIUM_PATH=google-chrome-stable\n\nscript:\n  # Run your build script that fetches a page and writes the output\n  - node generate_static_page.js\n```\n\n\n# Related links\n\n* [static-site-generator-webpack-plugin](https://github.com/markdalgleish/static-site-generator-webpack-plugin) webpack plugin that generates static pages from your universal application.\n* [react-snapshot](https://github.com/geelen/react-snapshot) runs your React application inside a fake browser, [jsdom](https://github.com/tmpvar/jsdom)\n* [prerender-spa-plugin](https://github.com/chrisvfritz/prerender-spa-plugin) webpack plugin that uses Phantom.JS.\n* [chrome-render](https://github.com/gwuhaolin/chrome-render) render any web page inside chrome headless browser, only works in node 7+.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiuccio%2Fprerender-chrome-headless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiuccio%2Fprerender-chrome-headless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiuccio%2Fprerender-chrome-headless/lists"}