{"id":19824531,"url":"https://github.com/BigRoomTechnologies/strange-router","last_synced_at":"2025-05-01T13:31:26.850Z","repository":{"id":32462867,"uuid":"109516505","full_name":"BigRoomStudios/strange-router","owner":"BigRoomStudios","description":"A module to aid bringing configurable routes to react-router v4.x","archived":false,"fork":false,"pushed_at":"2022-04-21T20:09:31.000Z","size":101,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-11T06:11:47.272Z","etag":null,"topics":["react","react-router"],"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/BigRoomStudios.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-11-04T17:43:17.000Z","updated_at":"2021-05-05T15:06:09.000Z","dependencies_parsed_at":"2022-08-07T17:31:13.529Z","dependency_job_id":null,"html_url":"https://github.com/BigRoomStudios/strange-router","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigRoomStudios%2Fstrange-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigRoomStudios%2Fstrange-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigRoomStudios%2Fstrange-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigRoomStudios%2Fstrange-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BigRoomStudios","download_url":"https://codeload.github.com/BigRoomStudios/strange-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224262119,"owners_count":17282267,"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":["react","react-router"],"created_at":"2024-11-12T11:04:21.974Z","updated_at":"2025-05-01T13:31:21.544Z","avatar_url":"https://github.com/BigRoomStudios.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# strange-router\n\nA module to aid bringing configurable routes to react-router v4\n\nLead Maintainer - [William Woodruff](https://github.com/wswoodruff)\n\n## Usage\n\n\u003e See also the [API Reference](API.md)\n\n```bash\nnpm install strange-router\n```\n\n### Config\n\n```js\nconst routes = [\n    {\n        path: 'first', // matches '/first'\n        component: MyComponent,\n        childRoutes: [\n            {\n                path: 'second', // matches '/first/second'\n                childRoutes: [\n                    { path: 'third', component: ThirdComponent }, // matches '/first/second/third'\n                    { redirect: { to: '/404' } } // catch all, redirects to absolute path '/404'\n                ]\n            },\n            { redirect: { from: 'oldPath', to: 'newPath' } } // '/first/oldPath' will redirect to '/first/newPath'\n            {\n                path: 'newPath',\n                component: NewStuff,\n                onWillMount: ({ route, match, location, history }) =\u003e {\n\n                    fetchSomeData();\n                },\n                onDidMount: ({ route, match, location, history }) =\u003e {\n\n                    logSomething();\n                },\n                onWillUnmount: ({ route, match, location, history }) =\u003e {\n\n                    cleanup();\n                },\n                componentDidCatch: ({ err, info, route, match, location, history }) =\u003e {\n\n                    handleErr(err);\n                    // and / or\n                    history.replace('/onErr', { err, info });\n                }\n            },\n            { redirect: { to: '/404' } } // catch all, redirects to absolute path '/404'\n        ]\n    },\n    {\n        path: '404',\n        component: FourOFour\n    },\n    {\n        path: 'onErr',\n        component: UhOhError\n    }\n];\n```\n\n### Integration (w/ redux)\n```js\nconst React = require('react');\nconst { Provider } = require('react-redux');\nconst { ConnectedRouter } = require('react-router-redux');\n\nconst StrangeRouter = require('strange-router');\n\nclass App extends React.PureComponent {\n\n    static propTypes = {\n        history: T.object.isRequired,\n        routes: T.array.isRequired,\n        store: T.object.isRequired\n    }\n\n    render() {\n\n        const { history, routes, store } = this.props;\n\n        return (\n            \u003cProvider store={store}\u003e\n                \u003cConnectedRouter history={history}\u003e\n                    \u003cStrangeRouter.Routes routes={routes} /\u003e\n                \u003c/ConnectedRouter\u003e\n            \u003c/Provider\u003e\n        );\n    }\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBigRoomTechnologies%2Fstrange-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBigRoomTechnologies%2Fstrange-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBigRoomTechnologies%2Fstrange-router/lists"}