{"id":13558362,"url":"https://github.com/yewstack/yew_router","last_synced_at":"2025-04-03T13:31:04.861Z","repository":{"id":53896454,"uuid":"138737689","full_name":"yewstack/yew_router","owner":"yewstack","description":"A routing library for the Yew frontend framework","archived":true,"fork":false,"pushed_at":"2020-04-27T07:34:04.000Z","size":754,"stargazers_count":91,"open_issues_count":6,"forks_count":23,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-12T20:49:12.475Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yewstack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-26T12:51:52.000Z","updated_at":"2025-03-09T11:52:18.000Z","dependencies_parsed_at":"2022-08-13T03:40:19.353Z","dependency_job_id":null,"html_url":"https://github.com/yewstack/yew_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/yewstack%2Fyew_router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yewstack%2Fyew_router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yewstack%2Fyew_router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yewstack%2Fyew_router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yewstack","download_url":"https://codeload.github.com/yewstack/yew_router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247009545,"owners_count":20868566,"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-01T12:04:54.677Z","updated_at":"2025-04-03T13:31:04.428Z","avatar_url":"https://github.com/yewstack.png","language":"Rust","readme":"# This project has been moved \nThis project has been incorporated into the [Yew](https://github.com/yewstack/yew) repository, and can specifically be found [here](https://github.com/yewstack/yew/tree/master/yew-router).\nYou should address all questions or improvements there instead of here.\nThis repository will be archived in the near future.\n\n\n# yew-router\nA routing library for the [Yew](https://github.com/yewstack/yew) frontend framework.\n\n\n### Example\n```rust\n#[derive(Switch, Debug)]\npub enum AppRoute {\n    #[to = \"/profile/{id}\"]\n    Profile(u32),\n    #[to = \"/forum{*:rest}\"]\n    Forum(ForumRoute),\n    #[to = \"/\"]\n    Index,\n}\n\n#[derive(Switch, Debug)]\npub enum ForumRoute {\n    #[to = \"/{subforum}/{thread_slug}\"]\n    SubForumAndThread{subforum: String, thread_slug: String}\n    #[to = \"/{subforum}\"]\n    SubForum{subforum: String}\n}\n\nhtml! {\n    \u003cRouter\u003cAppRoute, ()\u003e\n        render = Router::render(|switch: AppRoute| {\n            match switch {\n                AppRoute::Profile(id) =\u003e html!{\u003cProfileComponent id = id/\u003e},\n                AppRoute::Index =\u003e html!{\u003cIndexComponent/\u003e},\n                AppRoute::Forum(forum_route) =\u003e html!{\u003cForumComponent route = forum_route/\u003e},\n            }\n        })\n    /\u003e\n}\n```\n\n### How it works\nThis library works by getting the url location from the browser and uses it to instantiate a type that implements Switch.\nSimply using `\u003ca\u003e\u003c/a\u003e` tags to go to your route will not work out of the box, and are inefficient because the server will return the whole app bundle again at best, and at worst just return a 404 message if the server isn't configured properly.\nUsing this library's RouteService, RouteAgent, RouterButton, and RouterLink to set the location via `history.push_state()` will change the route without retrieving the whole app again.\n#### Server configuration\nIn order for an external link to your webapp to work, the server must be configured to return the `index.html` file for any GET request that would otherwise return a `404` for any conceivable client-side route.\nIt can't be a `3xx` redirect to `index.html`, as that will change the url in the browser, causing the routing to fail - it must be a `200` response containing the content of `index.html`.\nOnce the content of `index.html` loads, it will in turn load the rest of your assets as expected and your app will start, the router will detect the current route, and set your application state accordingly.\n\nIf you choose to serve the app from the same server as your api, it is recommended to mount your api under `/api` and mount your assets under `/` and have `/` return the content of `index.html`.\n\nLook at https://webpack.js.org/configuration/dev-server/#devserverhistoryapifallback for info on how to configure a webpack dev server to have this behavior.\n\n\n### How to Include\nYou can use the released version by adding these to your dependencies.\n```toml\n[dependencies]\nyew-router = \"0.7.0\"\nyew = \"0.10.1\"\n```\n\nYou can use the in-development version in your project by adding it to your dependencies like so:\n```toml\n[dependencies]\nyew-router = { git = \"https://github.com/yewstack/yew_router\", branch=\"master\" }\nyew = {git = \"https://github.com/yewstack/yew\", branch = \"master\"}\n```\n\n\n#### Minimum rustc\nCurrently, this library targets rustc 1.39.0, but development is done on the latest stable release.\nThis library aims to track Yew`s minimum supported rustc version.\n\n-----\n### Contributions/Requests\n\nIf you have any questions, suggestions, or want to contribute, please open an Issue or PR and we will get back to you in a timely manner.\n","funding_links":[],"categories":["Rust","others"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyewstack%2Fyew_router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyewstack%2Fyew_router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyewstack%2Fyew_router/lists"}