{"id":16888174,"url":"https://github.com/threepointone/react-router-modules","last_synced_at":"2025-04-11T12:50:30.337Z","repository":{"id":66100128,"uuid":"81378777","full_name":"threepointone/react-router-modules","owner":"threepointone","description":"react-modules + react-router + 🌈","archived":false,"fork":false,"pushed_at":"2017-02-10T10:46:36.000Z","size":57,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T09:11:12.267Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/threepointone.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-02-08T21:39:33.000Z","updated_at":"2020-06-11T17:54:10.000Z","dependencies_parsed_at":"2023-07-07T18:31:14.496Z","dependency_job_id":null,"html_url":"https://github.com/threepointone/react-router-modules","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threepointone%2Freact-router-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threepointone%2Freact-router-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threepointone%2Freact-router-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threepointone%2Freact-router-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/threepointone","download_url":"https://codeload.github.com/threepointone/react-router-modules/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248402655,"owners_count":21097338,"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":[],"created_at":"2024-10-13T16:49:44.940Z","updated_at":"2025-04-11T12:50:30.329Z","avatar_url":"https://github.com/threepointone.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"react-router-modules\n---\n\n[work in progress]\n\nto prpl and beyond\n\nusage \n--- \n\n`npm install @threepointone/react-router-modules`\n\nadd `@threepointone/react-router-modules/babel` to your babel plugins \n\n\nthe big idea \n---\n\nwe make a single change to the `\u003cRoute/\u003e` api\n\n```diff\n- import User from './user.js'\n\u003cRoute path='/user/:id'\n-  component={User}\n+  module='./user.js'\n/\u003e\n```\n\n- no new imports/apis, everything works as usual\n- renders default export by default \n- handles code splitting, SSR, behind the scenes \n- works with `render`, `children` props as expected \n\n```jsx\n\u003cRoute path='/user/:id'\n  module='./user.js'\n  render={ ({ Module }) =\u003e Module ? \n    \u003cModule.Profile /\u003e : \n    \u003cspan\u003eloading...\u003c/span\u003e )}\n/\u003e\n// or use children-func, to render even when path doesn't match\n\n``` \n\n- todo - preserve server side rendered html while module asyncly loads \n\n```jsx\n\u003cRoute path='/user/:id'\n  module='./user.js'\n  preserve /\u003e\n// this will render SSR, but split code out and load separately\n// server side rendered html will stay till module loads(!)\n```\n\n- todo - statically extract mapping of url -\u003e modules\n\n```jsx\nmatchModule('/user/213', { Module } =\u003e {\n  // and then fetch data, render \u003cApp /\u003e, whatever you like \n})\n\n// you can now expose this via an api endpoint. and handle data fetching, etc \n// this can also get treeshaked out lol\n```\n\n- use in tandem with your server for PRPL\n```jsx\n// TODO\n```\n\nconstraints -\n- For SSR to work, `path` has to be a static string\n\ntodo - \n\n- auto endpoints for data fetching \n- prefetch links\n- `\u003cHtml/\u003e`\n- service workers\n- all that jazz\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreepointone%2Freact-router-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthreepointone%2Freact-router-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreepointone%2Freact-router-modules/lists"}