{"id":13808084,"url":"https://github.com/hez2010/BlazorRouter","last_synced_at":"2025-05-14T02:31:12.944Z","repository":{"id":36179739,"uuid":"194316330","full_name":"hez2010/BlazorRouter","owner":"hez2010","description":"An awesome router for blazor.","archived":false,"fork":false,"pushed_at":"2025-02-11T21:46:31.000Z","size":5153,"stargazers_count":67,"open_issues_count":4,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T12:13:04.324Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","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/hez2010.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-28T18:17:58.000Z","updated_at":"2025-03-16T16:16:37.000Z","dependencies_parsed_at":"2024-04-09T21:28:59.448Z","dependency_job_id":"9f778f15-8eb3-47f0-a1d3-29fe9afeb01a","html_url":"https://github.com/hez2010/BlazorRouter","commit_stats":{"total_commits":47,"total_committers":3,"mean_commits":"15.666666666666666","dds":0.2978723404255319,"last_synced_commit":"73ed513d9b9940e5bc997318a6727a61b337c76c"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hez2010%2FBlazorRouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hez2010%2FBlazorRouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hez2010%2FBlazorRouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hez2010%2FBlazorRouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hez2010","download_url":"https://codeload.github.com/hez2010/BlazorRouter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253615033,"owners_count":21936583,"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-04T01:01:34.791Z","updated_at":"2025-05-14T02:31:07.906Z","avatar_url":"https://github.com/hez2010.png","language":"C#","funding_links":[],"categories":["Libraries \u0026 Extensions"],"sub_categories":["Tools \u0026 Utilities"],"readme":"# BlazorRouter [![nuget](https://img.shields.io/nuget/vpre/Hez2010.BlazorRouter.svg)](https://www.nuget.org/packages/Hez2010.BlazorRouter)\nAn awesome router for blazor inspired by react-router, providing declarative routing for Blazor.\n\n## Installation\nVia nuget package:\n```\ndotnet add package Hez2010.BlazorRouter\n```\nThen append `@using BlazorRouter` to your `_Imports.razor`\n\n## Usage\nPut `\u003cSwitch\u003e` to the place where you want to route your contents.  \nThen use `\u003cRoute\u003e` to config routing template with `Template` property.  \nIn the end, you can put the routed content inside the `\u003cRoute\u003e`.  \n\nParameters in the routing template will be passed as `IDictionary\u003cstring, object\u003e` with attribute `[CascadingParameter(Name = \"RouteParameters\")]`.  \n\nThe order of routing is from the top to the bottom in `\u003cSwitch\u003e`, and it will use the first matched item.  \nIf `Template` was not defined or defined as empty, it will match any path. \n\nFor example:\n```html\n\u003cSwitch\u003e\n    \u003cRoute Template=\"/\"\u003e\n        \u003cHome /\u003e\n    \u003c/Route\u003e\n    \u003cRoute Template=\"/login\"\u003e\n        \u003cAccount Action=\"Login\" /\u003e\n    \u003c/Route\u003e\n    \u003cRoute Template=\"/register\"\u003e\n        \u003cAccount Action=\"Register\" /\u003e\n    \u003c/Route\u003e\n    \u003cRoute Template=\"/user/{id:string}\"\u003e\n        \u003cUser /\u003e\n    \u003c/Route\u003e\n    \u003cRoute\u003e\n        \u003cp\u003e404\u003c/p\u003e\n    \u003c/Route\u003e\n\u003c/Switch\u003e\n```\n\nBesides, you can nest `Switch` to use nested routing:\n\nFor example:\n```html\n\u003cSwitch\u003e\n    \u003cRoute Template=\"/\"\u003e\n        \u003cHome /\u003e\n    \u003c/Route\u003e\n    \u003cRoute Template=\"/login\"\u003e\n        \u003cAccount Action=\"Login\" /\u003e\n    \u003c/Route\u003e\n    \u003cRoute Template=\"/register\"\u003e\n        \u003cAccount Action=\"Register\" /\u003e\n    \u003c/Route\u003e\n    \u003cRoute Template=\"/user/{id:string}/*\"\u003e\n        \u003cSwitch\u003e\n            \u003cRoute Template=\"/user/{id:string}/edit\"\u003e\n                \u003cUser Action=\"Edit\" /\u003e\n            \u003c/Route\u003e\n            \u003cRoute Template=\"/user/{id:string}/delete\"\u003e\n                \u003cUser Action=\"Delete\" /\u003e\n            \u003c/Route\u003e\n            \u003cRoute\u003e\n                \u003cp\u003e404 in /user/id\u003c/p\u003e\n            \u003c/Route\u003e\n        \u003c/Switch\u003e\n    \u003c/Route\u003e\n    \u003cRoute\u003e\n        \u003cp\u003e404\u003c/p\u003e\n    \u003c/Route\u003e\n\u003c/Switch\u003e\n```\n\n`*` represents one (can be zero if it's the last segment in template) segment, and you can use `**` to match multiple segments (\u003e= 0).\n\nNote: `**` can only be the last segment.\n\n```html\n\u003cSwitch\u003e\n    \u003cRoute Template=\"/\"\u003e\n        \u003cHome /\u003e\n    \u003c/Route\u003e\n    \u003cRoute Template=\"/login\"\u003e\n        \u003cAccount Action=\"Login\" /\u003e\n    \u003c/Route\u003e\n    \u003cRoute Template=\"/register\"\u003e\n        \u003cAccount Action=\"Register\" /\u003e\n    \u003c/Route\u003e\n    \u003cRoute Template=\"/user/*/edit\"\u003e\n        \u003cUser Action=\"Edit\" /\u003e\n    \u003c/Route\u003e\n    \u003cRoute Template=\"/user/*/delete\"\u003e\n        \u003cUser Action=\"Delete\" /\u003e\n    \u003c/Route\u003e\n    \u003cRoute\u003e\n        \u003cp\u003e404\u003c/p\u003e\n    \u003c/Route\u003e\n\u003c/Switch\u003e\n```\n\n## Live Example\n[Visit Sample](https://hez2010.github.io/BlazorRouter)  \nFor source, please check out `BlazorRouter.Sample`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhez2010%2FBlazorRouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhez2010%2FBlazorRouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhez2010%2FBlazorRouter/lists"}