{"id":19864183,"url":"https://github.com/hyper-ui/router","last_synced_at":"2026-06-09T08:32:22.245Z","repository":{"id":57116979,"uuid":"166654341","full_name":"hyper-ui/router","owner":"hyper-ui","description":"Official router for hyper-ui.","archived":false,"fork":false,"pushed_at":"2019-01-31T03:17:00.000Z","size":83,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-22T15:40:46.069Z","etag":null,"topics":["3h","client","hash","history","hui","hyper-ui","local","route","router","routing","switch"],"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/hyper-ui.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-01-20T11:39:16.000Z","updated_at":"2019-07-13T12:10:24.000Z","dependencies_parsed_at":"2022-08-22T22:20:23.954Z","dependency_job_id":null,"html_url":"https://github.com/hyper-ui/router","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hyper-ui/router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper-ui%2Frouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper-ui%2Frouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper-ui%2Frouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper-ui%2Frouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyper-ui","download_url":"https://codeload.github.com/hyper-ui/router/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper-ui%2Frouter/sbom","scorecard":{"id":475172,"data":{"date":"2025-08-11","repo":{"name":"github.com/hyper-ui/router","commit":"0e19917181a4d6e120bafbff289e43376060c619"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/25 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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":0,"reason":"26 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"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-19T15:06:24.638Z","repository_id":57116979,"created_at":"2025-08-19T15:06:24.638Z","updated_at":"2025-08-19T15:06:24.638Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34098931,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"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":["3h","client","hash","history","hui","hyper-ui","local","route","router","routing","switch"],"created_at":"2024-11-12T15:17:43.103Z","updated_at":"2026-06-09T08:32:22.225Z","avatar_url":"https://github.com/hyper-ui.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @hyper-ui/router\n\n\u003e Official router for [`hyper-ui`](https://github.com/hyper-ui/core).\n\n## TOC\n\n- [Introduction](#introduction)\n- [Usage](#usage)\n- [API Reference](#api-reference)\n- [Example](#example)\n- [Links](#links)\n\n## Introduction\n\nThis is the official router lib for [`@hyper-ui/core`](https://www.npmjs.com/package/@hyper-ui/core) and should be used with that package.\n\n## Usage\n\n### npm\n\n1. Use npm to install it together with `@hyper-ui/core`:\n\n    ```bash\n    npm install @hyper-ui/router @hyper-ui/core\n    ```\n\n2. Import the exports of this lib:\n\n    ```js\n    // es2015+\n    import * as HRouter from \"@hyper-ui/router\";\n    // es5\n    const HRouter = require(\"@hyper-ui/router\");\n    ```\n\n3. Use it to build your app.\n\n### CDN\n\n1. Put one of the following script tags after the one of `@hyper-ui/core` in your HTML file:\n\n    via jsdelivr:\n\n    ```html\n    \u003cscript type=\"text/javascript\" crossorigin=\"anonymous\" src=\"https://cdn.jsdelivr.net/npm/@hyper-ui/router@latest/dist/hyper-ui.router.umd.min.js\"\u003e\u003c/script\u003e\n    ```\n\n    or via unpkg:\n\n    ```html\n    \u003cscript type=\"text/javascript\" crossorigin=\"anonymous\" src=\"https://unpkg.com/@hyper-ui/router@latest/dist/hyper-ui.router.umd.min.js\"\u003e\u003c/script\u003e\n    ```\n\n2. Access the APIs via the `HRouter` global.\n\nIf you want a specified version, just replace `latest` with that in the url. By the way, it is recommended to use a specified version in production.\n\nFor more information about these two CDN sites, visit [www.jsdelivr.com](https://www.jsdelivr.com) or [unpkg.com](https://unpkg.com).\n\n## API Reference\n\n### HRouter\n\nIf you load the UMD module of this lib, an `HRouter` global will contain all the APIs. Otherwise, you use this package as a dependency and import the APIs from it.\n\n### HRouter.create\n\n```ts\nfunction create(factory: RouterFactory, options?: RouterFactoryOptions): Router;\n```\n\nThis is a factory function which accepts the router factory and options for it and returns the router. A router factory should receive the options and return a router instance. Built-in router factories are: [`HRouter.History`](#hrouterhistory), [`HRouter.Hash`](#hrouterhash) and [`HRouter.Local`](#hrouterlocal).\n\n### HRouter.Router\n\nThis is just an interface, not a value. Each router should have some universal methods:\n\n#### router.push\n\n```ts\nfunction push(path: string): void;\n```\n\nThis method lets you go to that path.\n\n#### router.pop\n\n```ts\nfunction pop(): void;\n```\n\nThis method lets you go back to previous path if there is one. (Nothing will happen if there is no such one.)\n\n#### router.getCurrent\n\n```ts\nfunction getCurrent(): string;\n```\n\nThis method returns current path.\n\n#### router.getHistorySize\n\n```ts\nfunction getHistorySize(): number;\n```\n\nThis method returns the current size of history.\n\n#### router.addListener\n\n```ts\nfunction addListener(listener: (path:string) =\u003e void): void;\n```\n\nThis method enables you to add a listener to the router. The listener will be invoked with every new path.\n\n#### router.removeListener\n\n```ts\nfunction removeListener(listener: (path:string) =\u003e void): void;\n```\n\nThis method lets you remove the given listener from the router.\n\n#### router.format\n\n```ts\nfunction format(path: string): string;\n```\n\nThis method receives the original path and returns a formated one.\n\n### HRouter.History\n\nThis is a history router factory. A history router uses [History APIs](https://developer.mozilla.org/en-US/docs/Web/API/History) to route.\n\nThe only option for a history router is `dropHash` which tells whether to drop the hash while routing. (Default: `false`)\n\n### HRouter.Hash\n\nThis is a hash router factory. A hash router uses the hash in url to route. (e.g. `www.example.com/#!/foo/bar`)\n\n### HRouter.Local\n\nThis is a local router factory. Each local router has its own state history.\n\nThe only option for a local router is `start` which stands for the initial state. (Default: `\"/\"`)\n\n### HRouter.Link\n\nThis is a symbol standing for link components which you can pass to `HUI` as the first argument to create links. A link component is quite like an anchor element except that it uses the specified router in its context to route.\n\nYou can use the `router` prop to tell a link the key to the router in its context. (Default: [`HRouter.DEFAULT_NAME`](#hrouterdefault_name))\n\nYou can also set `back` prop to `true` to let the link point to previous path.\n\n### HRouter.Route\n\nThis is a symbol standing for route components which you can pass to `HUI` as the first argument to create routes. Each route component accepts a `router` prop to specify which router in its context should be used. (Default: [`HRouter.DEFAULT_NAME`](#hrouterdefault_name))\n\nIn addition, it requires a matching prop and a rendering prop.\n\nA matching prop tells when the path matches the route. Available matching props: (sorted by priority)\n\n- `pattern` - A regular expression used to test the path.\n- `path` - A string used to be compared with the path.\n\nA rendering prop tells what to be rendered according to whether the path matches the route. Available rendering props: (sorted by priority)\n\n- `render` - A function receives a boolean and returns what should be rendered. (The boolean will be `true` when the path matches the route.)\n- `component` - A symbol standing for the component which should be rendered when the path matches the route.\n- `children` - What you want to render when the path matches the route.\n\n### HRouter.DEFAULT_NAME\n\nThis is a value which is the default value of `router` props of link components and route components.\n\n## Example\n\nHere is an example of basic usage:\n\n```js\n// Get the APIs\nconst { create, Route, Link } = HRouter;\n\n// Create routers\nconst historyRouter = {\n    name: HRouter.DEFAULT_NAME,\n    router: create(HRouter.History)\n};\nconst hashRouter = {\n    name: 'hash-router',\n    router: create(HRouter.Hash)\n};\nconst localRouter = {\n    name: 'local-router',\n    router: create(HRouter.Local, {\n        start: 'foo'\n    })\n};\n\n// Define the test component\nconst TestComponent = HUI.define('TestComponent', {\n    render() {\n        return HUI('p', null, 'Here is the test component.');\n    }\n});\n\n// Render the app\nHUI.render(\n    [\n\n        HUI('section', null, [\n\n            HUI('h1', null, 'History Routing'),\n\n            /**\n             * This route doesn't need a `router` prop\n             * because the history router is stored\n             * in the context using the default name.\n             */\n            HUI(Route, {\n                path: '/',\n                render: matched =\u003e HUI('p', null, [\n                    matched ?\n                        'The path is \"/\" now.' :\n                        'The path is not \"/\" now.'\n                ])\n            })\n\n        ]),\n\n        HUI('section', null, [\n\n            HUI('h1', null, 'Hash Routing'),\n\n            /**\n             * The routes and the links in this\n             * section do need `router` props\n             * because the hash router is stored\n             * in the context using a custom name.\n             */\n\n            HUI(Route, {\n                router: hashRouter.name,\n                pattern: /^\\/test/,\n                component: TestComponent\n            }),\n\n            HUI(Link, {\n                router: hashRouter.name,\n                href: '/',\n                onclick: function (event) {\n                    console.log('click event:', event);\n                }\n            }, 'Goto \"#!/\"'),\n\n            HUI('br'),\n\n            HUI(Link, {\n                router: hashRouter.name,\n                href: '/test',\n                ref: function (a) {\n                    console.log('anchor element reference:', a);\n                }\n            }, 'Goto \"#!/test\"'),\n\n            HUI('br'),\n\n            HUI(Link, {\n                router: hashRouter.name,\n                back: true\n            }, 'Go back')\n\n        ]),\n\n        HUI('section', null, [\n\n            HUI('h1', null, 'Local Routing'),\n\n            HUI(Route, {\n                router: localRouter.name,\n                path: 'foo',\n                render: matched =\u003e HUI('p', null, [\n                    `Current path is \"${matched ? 'foo' : 'bar'}\".`\n                ])\n            }),\n\n            HUI(Link, {\n                router: localRouter.name,\n                href: 'foo'\n            }, 'foo'),\n\n            HUI('br'),\n\n            HUI(Link, {\n                router: localRouter.name,\n                href: 'bar'\n            }, 'bar')\n\n        ])\n\n    ], {\n        defaultContext: {\n            [historyRouter.name]: historyRouter.router,\n            [hashRouter.name]: hashRouter.router,\n            [localRouter.name]: localRouter.router\n        }\n    }\n);\n```\n\n## Links\n\n- [Changelog](https://github.com/hyper-ui/router/blob/master/CHANGELOG.md)\n- [License (MIT)](https://github.com/hyper-ui/router/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyper-ui%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyper-ui%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyper-ui%2Frouter/lists"}