{"id":14977659,"url":"https://github.com/lhz516/react-code-split-ssr","last_synced_at":"2025-09-10T08:09:39.935Z","repository":{"id":90360207,"uuid":"102996182","full_name":"lhz516/react-code-split-ssr","owner":"lhz516","description":"React code splitting with server side rendering","archived":false,"fork":false,"pushed_at":"2017-09-11T05:11:34.000Z","size":9,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-09T14:21:05.138Z","etag":null,"topics":["code-splitting","react","react-router","server-side-rendering","ssr"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/lhz516.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-10T01:49:20.000Z","updated_at":"2020-06-04T19:52:13.000Z","dependencies_parsed_at":"2023-06-07T21:45:33.610Z","dependency_job_id":null,"html_url":"https://github.com/lhz516/react-code-split-ssr","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"6c88ff036e438c804a078c1d1baf6d28442e267c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lhz516/react-code-split-ssr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhz516%2Freact-code-split-ssr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhz516%2Freact-code-split-ssr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhz516%2Freact-code-split-ssr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhz516%2Freact-code-split-ssr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lhz516","download_url":"https://codeload.github.com/lhz516/react-code-split-ssr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhz516%2Freact-code-split-ssr/sbom","scorecard":{"id":587289,"data":{"date":"2025-08-11","repo":{"name":"github.com/lhz516/react-code-split-ssr","commit":"6c88ff036e438c804a078c1d1baf6d28442e267c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.4,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/6 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":5,"reason":"5 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T20:53:20.637Z","repository_id":90360207,"created_at":"2025-08-20T20:53:20.637Z","updated_at":"2025-08-20T20:53:20.637Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274429224,"owners_count":25283333,"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","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["code-splitting","react","react-router","server-side-rendering","ssr"],"created_at":"2024-09-24T13:56:05.554Z","updated_at":"2025-09-10T08:09:39.893Z","avatar_url":"https://github.com/lhz516.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Code Split SSR\nReact code splitting with server side rendering\n\n## How it works\n\n- Based on React Router 4\n- Server side: Load all components synchronously, then render to string.\n- Client side: Load the initial component before rendering, render the entire screen synchronously, then load the rest of routes asynchronously.\n\n#### Note: This packages is only tested in Meteor projects, but technically it can be used in any Nodejs projects. Here is an [example](https://github.com/lhz516/react-code-split-ssr-example) with Meteor\n\n## Usage\n```\n$ npm i react-code-split-ssr --save\n```\nClient/server shared:\n```js\nimport { Bundle } from 'react-code-split-ssr'\nimport React from 'react'\n\nconst Home = () =\u003e \u003cBundle mod={import('/imports/modules/home')} /\u003e\nconst Posts = () =\u003e \u003cBundle mod={import('/imports/modules/posts')} /\u003e\n\nexport const routes = [\n  { exact: true, path: '/', component: Home },\n  { exact: true, path: '/posts', component: Posts },\n]\n\nexport const redirects = [\n  { from: '/test', to: '/posts' }\n]\n```\nClient:\n```js\nimport  React from 'react'\nimport { render } from 'react-dom'\nimport { matchPath } from 'react-router'\nimport { BrowserRouter, Route, Switch } from 'react-router-dom'\nimport { generateRoutes } from 'react-code-split-ssr'\nimport { routes, redirects } from '/imports/routes'\n// import some components...\n\n/* In an async function */\nconst Routes = await generateRoutes({\n  routes,\n  redirects,\n  notFoundComp: NotFound,\n  pathname: window.location.pathname,\n})\nrender(\n  \u003cBrowserRouter\u003e\n    \u003cLayout\u003e\n      \u003cRoutes /\u003e\n    \u003c/Layout\u003e\n  \u003c/BrowserRouter\u003e,\n  document.getElementById('app'),\n)\n```\nServer:\n```js\nimport { Route, StaticRouter, Switch } from 'react-router'\nimport React from 'react'\nimport { renderToString } from 'react-dom/server'\nimport { generateRoutes } from 'react-code-split-ssr'\nimport { routes, redirects } from '/imports/routes'\n// import some components...\n\n/* In an async server router */\nconst Routes = await generateRoutes({\n  routes,\n  redirects,\n  notFoundComp: NotFound,\n  pathname: req.url\n})\n\nconst ServerRoutes = ({url, context = {}}) =\u003e (\n  \u003cStaticRouter\n    location={url.pathname}\n    context={context}\n  \u003e\n    \u003cLayout\u003e\n      \u003cRoutes /\u003e\n    \u003c/Layout\u003e\n  \u003c/StaticRouter\u003e\n)\nconst bodyHtmlString = renderToString(\u003cServerRoutes url={sink.request.url} /\u003e)\n// Use bodyHtmlString to where you need\n```\n\n## API\n\n### Bundle - React Component \\\u003cBundle\\\u003e\n#### Props\n- mod {Promise\u003cComponent\u003e} ***Required*** - A `Promise` object which can be resolved to React Component\n- loading {Component} - A React Component\n\n### generateRoutes - Func (object: Options)\nA function that returns a `Promise` object which can be resolved to React Router routes wrapped in `\u003cSwitch\u003e`\n\n#### Options\n- pathname {string} ***Required*** - Pathname for initial loading\n- routes {objects}[] ***Required*** - An array of `\u003cRoute\u003e` props object\n  - `component` field only accepts `() =\u003e \u003cBundle/\u003e`\n  - `location`, `render` fields are currently not supported\n- redirects  {objects}[] - An array of `\u003cRedirect\u003e` props object\n- notFoundComp {Component} - A React component for 404 Not Found, only accepts `() =\u003e \u003cBundle/\u003e`\n\n## v1.0.0 TODO\n- [ ] SSR correctly for redirected routes\n- [X] Change `notFoundComp` to `() =\u003e \u003cBundle /\u003e`\n- [ ] Add more argument validations\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flhz516%2Freact-code-split-ssr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flhz516%2Freact-code-split-ssr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flhz516%2Freact-code-split-ssr/lists"}