{"id":20060672,"url":"https://github.com/ficusjs/ficusjs-router","last_synced_at":"2025-05-05T15:33:22.081Z","repository":{"id":52977549,"uuid":"299558714","full_name":"ficusjs/ficusjs-router","owner":"ficusjs","description":"Lightweight client-side router that supports history and hash routing plus web components","archived":false,"fork":false,"pushed_at":"2024-10-10T21:02:01.000Z","size":1577,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-11T21:23:16.184Z","etag":null,"topics":["ficusjs","front-end","javascript","router","routing","web-components"],"latest_commit_sha":null,"homepage":"https://docs.ficusjs.org/router/","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/ficusjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["ficusjs"]}},"created_at":"2020-09-29T08:51:33.000Z","updated_at":"2024-10-10T20:59:25.000Z","dependencies_parsed_at":"2023-02-19T04:30:55.697Z","dependency_job_id":null,"html_url":"https://github.com/ficusjs/ficusjs-router","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ficusjs%2Fficusjs-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ficusjs%2Fficusjs-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ficusjs%2Fficusjs-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ficusjs%2Fficusjs-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ficusjs","download_url":"https://codeload.github.com/ficusjs/ficusjs-router/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224452752,"owners_count":17313668,"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":["ficusjs","front-end","javascript","router","routing","web-components"],"created_at":"2024-11-13T13:16:16.347Z","updated_at":"2024-11-13T13:16:17.063Z","avatar_url":"https://github.com/ficusjs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ficusjs"],"categories":[],"sub_categories":[],"readme":"# FicusJS router\n\n\u003cimg src=\"img/ficus-icon.svg\" alt=\"FicusJS\" width=\"150\" align=\"right\"\u003e\n\nLightweight standalone client-side router that supports history and hash routing.\n\n## Features\n\n- Declarative route set-up\n- Two modes of routing - history and hash\n- Routes render web components or HTML strings\n- Routes can be sync or async\n- Provide context to routes\n- Handle redirects from routes\n- Named URL parameters\n- Guard navigations by redirecting or cancelling\n- Outlets act as placeholders for rendering content per route\n- Control navigation with methods\n- Lazy load views based on route\n- Start router programmatically\n\n## Documentation\n\nSee the [full documentation](https://docs.ficusjs.org/router).\n\n## Getting started\n\nThe easiest way to try out FicusJS router is using a simple example.\n\nCreate an `index.html` file and copy the following between the `\u003cbody\u003e` tags.\n\n```html\n\u003ctop-nav\u003e\u003c/top-nav\u003e\n\u003cdiv id=\"router-outlet\"\u003e\u003c/div\u003e\n\n\u003cscript type=\"module\"\u003e\nimport { createRouter } from 'https://cdn.skypack.dev/@ficusjs/router@3'\nimport { createComponent } from 'https://cdn.skypack.dev/ficusjs@5'\nimport { renderer, html } from 'https://cdn.skypack.dev/@ficusjs/renderers@5/lit-html'\n\ncreateComponent('home-page', {\n  renderer,\n  render () {\n    return html`\u003cdiv\u003eWelcome to the home page!\u003c/div\u003e`\n  }\n})\n\ncreateComponent('page-one', {\n  renderer,\n  render () {\n    return html`\u003cdiv\u003eWelcome to the page one!\u003c/div\u003e`\n  }\n})\n\ncreateComponent('page-two', {\n  renderer,\n  render () {\n    return html`\u003cdiv\u003eWelcome to the page two!\u003c/div\u003e`\n  }\n})\n\nconst router = createRouter([\n  { path: '', component: 'home-page' },\n  { path: '/one', component: 'page-one' },\n  { path: '/two', component: 'page-two' }\n], '#router-outlet', { mode: 'hash' })\n\ncreateComponent('top-nav', {\n  renderer,\n  navigateTo (path) {\n    router.push(path)\n  },\n  render () {\n    return html`\n      \u003cnav\u003e\n        \u003cul\u003e\n          \u003cli\u003e\u003cbutton type=\"button\" @click=\"${() =\u003e this.navigateTo('/')}\"\u003eHome\u003c/button\u003e\u003c/li\u003e\n          \u003cli\u003e\u003cbutton type=\"button\" @click=\"${() =\u003e this.navigateTo('/one')}\"\u003ePage one\u003c/button\u003e\u003c/li\u003e\n          \u003cli\u003e\u003cbutton type=\"button\" @click=\"${() =\u003e this.navigateTo('/two')}\"\u003ePage two\u003c/button\u003e\u003c/li\u003e\n        \u003c/ul\u003e\n      \u003c/nav\u003e\n    `\n  }\n})\n\u003c/script\u003e\n```\n\n\u003e Alternatively, fork this Codepen to see it in action - [https://codepen.io/ducksoupdev/pen/PoNvGwK](https://codepen.io/ducksoupdev/pen/PoNvGwK)\n\nThe example creates a set of page components, a page navigation component and a new router using hash mode.\n\n## Installation\n\nFicusJS router can be installed in a number of ways.\n\n### CDN\n\nWe recommend using native ES modules in the browser.\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { createRouter, getRouter } from 'https://cdn.skypack.dev/@ficusjs/router@3'\n\u003c/script\u003e\n```\n\nFicusJS router is available on [Skypack](https://www.skypack.dev/view/@ficusjs/router).\n\n### NPM\n\nFicusJS router works nicely with build tools such as Webpack or Rollup. If you are using a NodeJS tool, you can install the NPM package.\n\n```bash\nnpm install @ficusjs/router\n```\n\n### Available builds\n\nFicusJS router is only available as an ES module. For legacy browsers or alternative modules such as CommonJS, it is recommended to use a build tool to transpile the code.\n\n## Development\n\nHow to set-up FicusJS router for local development.\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/ficusjs/ficusjs-router.git\n```\n\n2. Change the working directory\n\n```bash\ncd ficusjs-router\n```\n\n3. Install dependencies\n\n```bash\nnpm install # or, yarn install\n```\n\n4. Run the local development server\n\n```bash\nnpm run dev # or, yarn dev\n```\n\nThat's it! Now open http://localhost:8080 to see a local app.\n\n## License\n\nThis project is licensed under the MIT License - see the [`LICENSE`](LICENSE) file for details.\n\n## Contributing to FicusJS router\n\nAny kind of positive contribution is welcome! Please help us to grow by contributing to the project.\n\nIf you wish to contribute, you can work on any features you think would enhance the library. After adding your code, please send us a Pull Request.\n\n\u003e Please read [CONTRIBUTING](CONTRIBUTING.md) for details on our [CODE OF CONDUCT](CODE_OF_CONDUCT.md), and the process for submitting pull requests to us.\n\n## Support\n\nWe all need support and motivation. FicusJS is not an exception. Please give this project a ⭐️ to encourage and show that you liked it. Don't forget to leave a star ⭐️ before you move away.\n\nIf you found the library helpful, please consider [sponsoring us](https://github.com/sponsors/ficusjs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fficusjs%2Fficusjs-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fficusjs%2Fficusjs-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fficusjs%2Fficusjs-router/lists"}