{"id":18392484,"url":"https://github.com/marwan-at-work/vecty-router","last_synced_at":"2025-04-07T03:34:08.338Z","repository":{"id":56494146,"uuid":"96687034","full_name":"marwan-at-work/vecty-router","owner":"marwan-at-work","description":"A declarative client-side router for Vecty applications. ","archived":false,"fork":false,"pushed_at":"2020-11-04T06:25:11.000Z","size":20,"stargazers_count":28,"open_issues_count":4,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-22T12:24:44.822Z","etag":null,"topics":["go","gopherjs","router","vecty"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/marwan-at-work.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-07-09T13:46:11.000Z","updated_at":"2023-04-17T22:15:30.000Z","dependencies_parsed_at":"2022-08-15T19:50:24.960Z","dependency_job_id":null,"html_url":"https://github.com/marwan-at-work/vecty-router","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marwan-at-work%2Fvecty-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marwan-at-work%2Fvecty-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marwan-at-work%2Fvecty-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marwan-at-work%2Fvecty-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marwan-at-work","download_url":"https://codeload.github.com/marwan-at-work/vecty-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247589706,"owners_count":20963022,"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":["go","gopherjs","router","vecty"],"created_at":"2024-11-06T01:57:02.639Z","updated_at":"2025-04-07T03:34:08.121Z","avatar_url":"https://github.com/marwan-at-work.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vecty Router\n\nA declarative client-side router for [Vecty](https://www.github.com/hexops/vecty) applications. \nSimilar to [react-router v4](https://github.com/ReactTraining/react-router)\n\n### Installation\n\n`go get marwan.io/vecty-router`\n\n### Usage\n\nYou don't need to declare your routes at the top level. You can declare them inside any component\nand if they match they will render, otherwise, router will render an empty div instead. \n\n```go\npackage components\n\nimport (\n\t\"github.com/hexops/vecty\"\n\t\"github.com/hexops/vecty/elem\"\n\t\"marwan.io/vecty-router\"\n)\n\n// Body renders the \u003cbody\u003e tag\ntype Body struct {\n\tvecty.Core\n}\n\n// Render renders the \u003cbody\u003e tag with the App as its children\nfunc (b *Body) Render() vecty.ComponentOrHTML {\n\treturn elem.Body(\n\t\trouter.NewRoute(\"/\", \u0026MainView{}, router.NewRouteOpts{ExactMatch: true}),\n\t\trouter.NewRoute(\"/blog\", \u0026Blog{}, router.NewRouteOpts{}),\n\t\trouter.NewRoute(\"/blog/{id}\", \u0026PostView{}, router.NewRouteOpts{ExactMatch: true}),\n\t)\n}\n```\n\nTo retrieve a named variable like {id} in the example above you can do\n\n```go\n// Render returns every title\nfunc (pv *PostView) Render() vecty.ComponentOrHTML {\n\tid := router.GetNamedVar(pv)[\"id\"]\n\treturn elem.Div(\n\t\tvecty.Text(id),\n\t)\n}\n```\n\n### Other features\n\n##### Navigation through links\n\n```go\nfunc (c *component) Render() vecty.ComponentOrHTML {\n\treturn elem.Span(\n\t\trouter.Link(\"/my/route\", \"click here\", router.LinkOptions{}),\n\t)\n}\n```\n\n##### Programatically navigate to a route\n\n```go\nrouter.Redirect(\"/my/route\")\n```\n\n### Status\n\nCurrently vecty-router does not fallback to hash routing if the History API is not on your browser.\nIt also calls vecty.Rerender on all routes whenever a route changes. It should/will do its own deducing of whether to call rerender on a route or not based on route matches and whether it's already mounted or not.\n\n### Alternatives\n\n- https://github.com/go-humble/router\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarwan-at-work%2Fvecty-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarwan-at-work%2Fvecty-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarwan-at-work%2Fvecty-router/lists"}