{"id":15683634,"url":"https://github.com/gwuhaolin/koa-chrome-render","last_synced_at":"2025-07-26T12:02:44.785Z","repository":{"id":80950169,"uuid":"93919205","full_name":"gwuhaolin/koa-chrome-render","owner":"gwuhaolin","description":"chrome-render middleware for koa","archived":false,"fork":false,"pushed_at":"2017-06-30T07:19:22.000Z","size":20,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-13T10:53:06.785Z","etag":null,"topics":["chrome","koa","middleware","render"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gwuhaolin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-10T06:01:02.000Z","updated_at":"2018-09-07T15:11:38.000Z","dependencies_parsed_at":"2023-03-12T12:49:11.359Z","dependency_job_id":null,"html_url":"https://github.com/gwuhaolin/koa-chrome-render","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.08333333333333337,"last_synced_commit":"d3f31f9d8692465f4eddea15b3d7b7e3cb3fb60c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gwuhaolin/koa-chrome-render","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gwuhaolin%2Fkoa-chrome-render","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gwuhaolin%2Fkoa-chrome-render/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gwuhaolin%2Fkoa-chrome-render/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gwuhaolin%2Fkoa-chrome-render/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gwuhaolin","download_url":"https://codeload.github.com/gwuhaolin/koa-chrome-render/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gwuhaolin%2Fkoa-chrome-render/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265200426,"owners_count":23726833,"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","koa","middleware","render"],"created_at":"2024-10-03T17:07:53.793Z","updated_at":"2025-07-26T12:02:44.735Z","avatar_url":"https://github.com/gwuhaolin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Npm Package](https://img.shields.io/npm/v/koa-chrome-render.svg?style=flat-square)](https://www.npmjs.com/package/koa-chrome-render)\n[![Npm Downloads](http://img.shields.io/npm/dm/koa-chrome-render.svg?style=flat-square)](https://www.npmjs.com/package/koa-chrome-render)\n[![Dependency Status](https://david-dm.org/gwuhaolin/koa-chrome-render.svg?style=flat-square)](https://npmjs.org/package/koa-chrome-render)\n\n# koa-chrome-render\n[chrome-render](https://github.com/gwuhaolin/chrome-render) middleware for koa.\n\nModern web app use technique like react.js vue.js which render html in browser, this cause some problem like search engine can't crawl your page content or first screen slow on low performance device.\n\nThis project want to solve this kind of problem in a general-purpose way which use headless chrome to render page result then return to client.\n\n## Use\n```bash\nnpm i koa-chrome-render\n```\nthen use it:\n```js\nconst Koa = require('koa');\nconst chromeRenderMiddleware = require('koa-chrome-render');\nconst app = new Koa();\n\napp.use(chromeRenderMiddleware({\n    enable: true,\n    render: {\n        // use `window.isPageReady=1` to notify chrome-render page has ready\n        useReady: true,\n    }\n}));\n\napp.listen(3000);\n```\nyou can download and run this [complete demo](./demo/main.js) which will use chrome-render for mobile device else return html direct.\n\n## Options\n\n### `enable` options\nshould enable this middleware for every single request ? it's type can be boolean or function.\nif type is function, result = enable(request);\nthis can be used to control whether use chrome to render in some case, e.g [koa-seo](https://github.com/gwuhaolin/koa-seo).\n\n### `render` options\noptions come form [chrome-render](https://github.com/gwuhaolin/chrome-render#chromerendernew-method-support-options)\n- `maxTab`: `number` max tab chrome will open to render pages, default is no limit, `maxTab` used to avoid open to many tab lead to chrome crash. `ChromeRender` will create a tab poll to reuse tab for performance improve and resource reduce as open and close tab in chrome require time, like database connection poll. \n- `renderTimeout`: `number` in ms, `chromeRender.render()` will throw error if html string can't be resolved after `renderTimeout`, default is 5000ms.\n- `useReady`: `boolean` whether use `window.isPageReady=1` to notify chrome-render page has ready. default is false chrome-render use `domContentEventFired` as page has ready.\n- `script`: `string` is an option param. inject script source to evaluate when page on load\n\nalso koa-chrome-render will read:\n- `headers` from request HTTP headers and attach to chrome-render's request\n- `cookies` from request HTTP headers and attach to chrome-render's request\n\n## Friends\n- koa-chrome-render dependent on [chrome-render](https://github.com/gwuhaolin/chrome-render) general server render base on chrome.\n- [koa-seo](https://github.com/gwuhaolin/koa-seo) koa SEO middleware\n- [chrome-pool](https://github.com/gwuhaolin/chrome-pool) Headless chrome tabs manage pool.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgwuhaolin%2Fkoa-chrome-render","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgwuhaolin%2Fkoa-chrome-render","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgwuhaolin%2Fkoa-chrome-render/lists"}