{"id":23128143,"url":"https://github.com/victorqueiroz/react-halter","last_synced_at":"2026-04-09T08:44:33.653Z","repository":{"id":34242431,"uuid":"173044771","full_name":"VictorQueiroz/react-halter","owner":"VictorQueiroz","description":"ReactJS bindings for easy and fast integration with Halter router","archived":false,"fork":false,"pushed_at":"2022-10-05T12:40:13.000Z","size":229,"stargazers_count":0,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T13:58:15.571Z","etag":null,"topics":["halter","lightweight","reactjs","router","simple"],"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/VictorQueiroz.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":"2019-02-28T05:08:20.000Z","updated_at":"2020-06-14T19:35:40.000Z","dependencies_parsed_at":"2023-01-15T05:46:16.743Z","dependency_job_id":null,"html_url":"https://github.com/VictorQueiroz/react-halter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VictorQueiroz%2Freact-halter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VictorQueiroz%2Freact-halter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VictorQueiroz%2Freact-halter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VictorQueiroz%2Freact-halter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VictorQueiroz","download_url":"https://codeload.github.com/VictorQueiroz/react-halter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128738,"owners_count":20888234,"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":["halter","lightweight","reactjs","router","simple"],"created_at":"2024-12-17T09:17:37.753Z","updated_at":"2026-04-09T08:44:33.518Z","avatar_url":"https://github.com/VictorQueiroz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-halter\n\nReactJS bindings for easy integration with Halter router.\n\n### Installation\n\n```\nyarn add react-halter\n```\n\n### Usage\n\nThe `RouterView` component lifecycle will determine what routes should be inside the given `Router` instance using the input `routes`. When `RouterView` is mounted it'll initialize the router instance and when it gets unmounted it'll clear all the routes and so forth\n\n```js\nimport { createBrowserHistory } from 'history';\nimport { RouterView } from 'react-halter';\nimport { Router } from 'halter';\nimport Login from './components/login/login';\nimport NavigationBar from './components/navigation-bar/navigation-bar';\nimport BackendAPI from './services/backend-api';\n\nfunction Post({ location: { params } }) {\n    const postId = params.get('id');\n    if(!postId) {\n        return null;\n    }\n    return (\n        \u003cdiv\u003e\n            \u003ch3\u003e{posts[postId].title}\u003c/h3\u003e\n            \u003cp\u003e{posts[postId].contents}\u003c/p\u003e\n        \u003c/div\u003e\n    );\n}\n\nfunction HomeWrapper({ children }){\n    return (\n        \u003cdiv\u003e\n            \u003cNavigationBar/\u003e\n            \u003cdiv\u003e\n                {children}\n            \u003c/div\u003e\n        \u003c/div\u003e\n    )\n}\n\nconst rules = {\n    isAuthenticated: async function(match, replaceState, pushState) {\n        if(await BackendAPI.isAuthenticated()){\n            replaceState('dashboard');\n            return true;\n        }\n    },\n    isGuest: async function(match, replaceState, pushState) {\n        if(await BackendAPI.isAuthenticated()){\n            return true;\n        }\n        replaceState('app.login');\n    }\n}\n\nconst routes = [{\n    path: '/',\n    name: 'app',\n    component: HomeWrapper,\n    childRoutes: [{\n        name: 'post',\n        path: 'posts/{id:[A-z0-9]+}',\n        component: Post\n    }, {\n        path: 'login',\n        name: 'login',\n        component: Login,\n        onBefore: rules.isAuthenticated\n    }]\n}, {\n    name: 'dashboard',\n    path: '/dashboard',\n    component: Dashboard,\n    onBefore: rules.isGuest\n}];\n\nReactDOM.render(\u003cdiv\u003e\n    \u003ch1\u003eMy first app\u003c/h1\u003e\n    \u003cRouterView\n        router={new Router(createBrowserHistory())}\n        routes={routes} /\u003e\n\u003c/div\u003e, document.getElementById('app'));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictorqueiroz%2Freact-halter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvictorqueiroz%2Freact-halter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictorqueiroz%2Freact-halter/lists"}