{"id":13605126,"url":"https://github.com/choojs/nanorouter","last_synced_at":"2025-06-20T04:08:17.990Z","repository":{"id":43642939,"uuid":"84775983","full_name":"choojs/nanorouter","owner":"choojs","description":"🛤 - Small frontend router","archived":false,"fork":false,"pushed_at":"2019-06-09T09:07:51.000Z","size":22,"stargazers_count":116,"open_issues_count":4,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-08T22:39:42.746Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/choojs.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-03-13T02:32:39.000Z","updated_at":"2023-08-05T22:03:25.000Z","dependencies_parsed_at":"2022-09-12T11:44:26.962Z","dependency_job_id":null,"html_url":"https://github.com/choojs/nanorouter","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/choojs/nanorouter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanorouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanorouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanorouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanorouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/choojs","download_url":"https://codeload.github.com/choojs/nanorouter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanorouter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260878464,"owners_count":23075962,"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-08-01T19:00:54.910Z","updated_at":"2025-06-20T04:08:12.980Z","avatar_url":"https://github.com/choojs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# nanorouter [![stability][0]][1]\n[![npm version][2]][3] [![build status][4]][5]\n[![downloads][8]][9] [![js-standard-style][10]][11]\n\nSmol frontend router\n\n## Usage\n```js\nvar nanorouter = require('nanorouter')\nvar router = nanorouter({ default: '/404' })\n\nrouter.on('/foo', function (params) {\n  console.log('hit /foo')\n})\nrouter.on('/foo/:bar', function (params) {\n  console.log('hit a route with params', params.bar)\n})\nrouter.on('/foo#baz', function (params) {\n  console.log('we do hash routes too!')\n})\nrouter.on('/foo/*', function (params) {\n  console.log('and even wildcards', params.wildcard)\n})\n\nrouter.emit('/foo/hello-planet')\n```\n\n## FAQ\n### How is this different from sheet-router?\n`sheet-router` does slightly more and has a different syntax. This router is\nlighter, faster and covers less concerns. They're pretty similar under the hood\nthough.\n\n## API\n### `router = nanorouter([opts])`\nCreate a new router. `opts` can be:\n- __opts.default:__ set a default handler in case no route matches. Defaults to\n  `/404`\n\n### `router.on(routename, handler(params))`\nRegister a handler on a routename. The handler receives an object with params\non each render. A result can be `return`ed the caller function.\n\n### `result = router.emit(routename)`\nCall a handler for a `routename`. If no handler matches, the handler specified\nin `opts.default` will be called. If no default handler matches, an error will\nbe thrown. Results returned from the called handler will be returned from this\nfunction.\n\n### `matchedRoute = router.match(route)`\nMatches a route and returns an object. The returned object contains the properties `{cb, params, route}`. This method does not invoke the callback of a route. If no route matches, the route specified in `opts.default` will be returned. If no default route matches, an error will be thrown.\n\nNote that `router()` does not affect browser history. If you would like to\nadd or modify history entries when you change routes, you should use\n[`history.pushState()` and `history.replaceState()`](https://developer.mozilla.org/en-US/docs/Web/API/History_API#Adding_and_modifying_history_entries)\nalongside `router()`.\n\n## See Also\n- [yoshuawuyts/sheet-router](https://github.com/yoshuawuyts/sheet-router)\n- [yoshuawuyts/wayfarer](https://github.com/yoshuawuyts/wayfarer)\n\n## License\n[MIT](https://tldrlegal.com/license/mit-license)\n\n[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square\n[1]: https://nodejs.org/api/documentation.html#documentation_stability_index\n[2]: https://img.shields.io/npm/v/nanorouter.svg?style=flat-square\n[3]: https://npmjs.org/package/nanorouter\n[4]: https://img.shields.io/travis/choojs/nanorouter/master.svg?style=flat-square\n[5]: https://travis-ci.org/choojs/nanorouter\n[6]: https://img.shields.io/codecov/c/github/choojs/nanorouter/master.svg?style=flat-square\n[7]: https://codecov.io/github/choojs/nanorouter\n[8]: http://img.shields.io/npm/dm/nanorouter.svg?style=flat-square\n[9]: https://npmjs.org/package/nanorouter\n[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[11]: https://github.com/feross/standard\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoojs%2Fnanorouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchoojs%2Fnanorouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoojs%2Fnanorouter/lists"}