{"id":14965065,"url":"https://github.com/angelmunoz/navs","last_synced_at":"2025-10-25T11:30:52.876Z","repository":{"id":205327397,"uuid":"713678056","full_name":"AngelMunoz/Navs","owner":"AngelMunoz","description":"A set of libraries that allow Router-like experiences for general purpose F# Apps","archived":false,"fork":false,"pushed_at":"2024-11-30T18:13:41.000Z","size":319,"stargazers_count":17,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"vnext","last_synced_at":"2025-02-07T23:53:36.994Z","etag":null,"topics":["avalonia","dotnet","fsharp","navigation","router","url-parser"],"latest_commit_sha":null,"homepage":"https://angelmunoz.github.io/Navs/","language":"F#","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/AngelMunoz.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":"2023-11-03T02:32:52.000Z","updated_at":"2024-12-01T22:36:57.000Z","dependencies_parsed_at":"2024-03-28T05:39:11.646Z","dependency_job_id":"7f761326-b0bb-4c7d-bdcd-385534f37819","html_url":"https://github.com/AngelMunoz/Navs","commit_stats":{"total_commits":114,"total_committers":1,"mean_commits":114.0,"dds":0.0,"last_synced_commit":"38161b73d647bece093766a2eab2683a202f4c48"},"previous_names":["angelmunoz/routerish","angelmunoz/navs"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngelMunoz%2FNavs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngelMunoz%2FNavs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngelMunoz%2FNavs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngelMunoz%2FNavs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AngelMunoz","download_url":"https://codeload.github.com/AngelMunoz/Navs/tar.gz/refs/heads/vnext","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238128493,"owners_count":19421046,"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":["avalonia","dotnet","fsharp","navigation","router","url-parser"],"created_at":"2024-09-24T13:34:10.191Z","updated_at":"2025-10-25T11:30:47.593Z","avatar_url":"https://github.com/AngelMunoz.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Navs Family\n\nWelcome to the Navs Family documentation.\n\nThis documentation is a work in progress.\n\nThis project contains the following libraries:\n\n- [Navs](#Navs)\n- [UrlTemplates](#UrlTemplates)\n- [Navs.Avalonia](#Navs-Avalonia)\n- [Navs.FuncUI](#Navs-FuncUI)\n\n### Navs\n\nNavs is a router-like abstraction inspired by web routers such as vue-router, angular-router and similar projects.\n\nIt is primarily a \"core\" library which you would usually depend on in your own projects, as it is very generic and while F# can be very intelligent about type inference, it tends to produce quite verbose signatures. For more information visit the Navs section in these docs.\n\n- [Navs](https://angelmunoz.github.io/Navs/Navs.html)\n\nA Compelling Example:\n\n```fsharp\n\nlet routes = [\n  Route.define\u003cstring\u003e(\"home\", \"/\", (fun _ -\u003e \"Home\"))\n  Route.define\u003cstring\u003e(\"about\", \"/about\", (fun _ -\u003e \"About\"))\n  Route.define\u003cstring\u003e(\n    \"guid\",\n    \"/:id\u003cguid\u003e\",\n    fun context _ -\u003e async {\n      do! Async.Sleep(90)\n      return\n        match context.getParam\u003cGuid\u003e \"id\" with\n        | ValueSome id -\u003e sprintf \"Home %A\" id\n        | ValueNone -\u003e \"Guid No GUID\"\n    }\n  )\n]\n\nlet router = Router.build\u003cstring\u003e(routes)\n\nrouter.Content.AddCallback(fun content -\u003e printfn $\"%A{content}\")\n\nlet! result1 = router.navigate(\"/about\")\nlet! result2 = router.navigate(\"/home\")\nlet! result3 = router.navigate(\"/123e4567-e89b-12d3-a456-426614174000\")\n\n// \"About\"\n// \"Home\"\n// \"Home 123e4567-e89b-12d3-a456-426614174000\"\n\n```\n\n### Navs.Avalonia\n\nThis project attempts to hide the generics from call sites and offer a few DSLs to make it easier to use Navs in Avalonia applications. This router was designed to be used with Raw Avalonia Control classes however, it will pair very nicely with the [NXUI](https://github.com/wieslawsoltes/NXUI) project, Feel free to check the C# and F# samples in the [Samples](https://github.com/AngelMunoz/Navs/tree/main/samples) folder in the source code repository.\n\n- [Navs.Avalonia](https://angelmunoz.github.io/Navs/Navs-Avalonia.html)\n\nA Compelling Example:\n\n```fsharp\n\nlet routes = [\n  Route.define(\n    \"guid\",\n    // routes can be typed!\n    \"/:id\u003cguid\u003e\",\n    fun context _ -\u003e async {\n      // you can pre-load data if you want to\n      do! Async.Sleep(90)\n      return\n        // extract parameters from the URL\n        match context.getParam\u003cguid\u003e \"id\" with\n        | ValueSome id -\u003e TextBlock().text(sprintf \"Home %A\" id)\n        | ValueNone -\u003e TextBlock().text(\"Guid No GUID\")\n    }\n  )\n  // Simpler non-async routes are also supported\n  Route.define(\"books\", \"/books\", (fun _ _ -\u003e TextBlock().text(\"Books\")))\n]\n\nlet navigate url (router: IRouter\u003cControl\u003e) _ _ =\n  task {\n    // navigation is asynchronous and returns a result\n    // in order to check if the navigation was successful\n    let! result = router.Navigate(url)\n\n    match result with\n    | Ok _ -\u003e ()\n    | Error e -\u003e printfn $\"%A{e}\"\n  }\n  |\u003e ignore\n\nlet app () =\n\n  let router: IRouter\u003cControl\u003e = AvaloniaRouter(routes, splash = fun _ -\u003e TextBlock().text(\"Loading...\"))\n\n  Window()\n    .content(\n      DockPanel()\n        .lastChildFill(true)\n        .children(\n          StackPanel()\n            .DockTop()\n            .OrientationHorizontal()\n            .spacing(8)\n            .children(\n              Button().content(\"Books\").OnClickHandler(navigate \"/books\" router),\n              Button()\n                .content(\"Guid\")\n                .OnClickHandler(navigate $\"/{Guid.NewGuid()}\" router)\n            ),\n          RouterOutlet().router(router)\n        )\n    )\n\n\nNXUI.Run(app, \"Navs.Avalonia!\", Environment.GetCommandLineArgs()) |\u003e ignore\n```\n\n### Navs.FuncUI\n\nIn a similar Fashion of Navs.Avalonia, this project attempts to provide a smooth API interface for [Avalonia.FuncUI](https://github.com/fsprojects/Avalonia.FuncUI/), you can find a sample in the [Samples](https://github.com/AngelMunoz/Navs/tree/main/samples) folder in the source code repository.\n\n- [Navs.FuncUI](https://angelmunoz.github.io/Navs/Navs-FuncUI.html)\n\nA Compelling Example:\n\n```fsharp\n\nlet routes = [\n  Route.define(\n    \"books\",\n    \"/books\",\n    (fun _ _ -\u003e TextBlock.create [ TextBlock.text \"Books\" ])\n  )\n  Route.define(\n    \"guid\",\n    \"/:id\u003cguid\u003e\",\n    fun context _ -\u003e async {\n      return\n        TextBlock.create [\n          match context.getParam\u003cguid\u003e \"id\" with\n          | ValueSome id -\u003e TextBlock.text $\"Visited: {id}\"\n          | ValueNone -\u003e TextBlock.text \"Guid No GUID\"\n        ]\n    }\n  )\n]\n\nlet appContent (router: IRouter\u003cIView\u003e, navbar: IRouter\u003cIView\u003e -\u003e IView) =\n  Component(fun ctx -\u003e\n\n    let currentView = ctx.useRouter router\n\n    DockPanel.create [\n      DockPanel.lastChildFill true\n      DockPanel.children [ navbar router; currentView.Current ]\n    ]\n  )\n```\n\n### UrlTemplates\n\nThis is a library for parsing URL-like strings into structured objects. It is used by Navs to parse navigable URLs and URL templates to find if they match.\n\nCurrently this library is mainly aimed to be used from F# but if there's interest in using it from C# I can add some more friendly APIs.\n\n- [UrlTemplates](https://angelmunoz.github.io/Navs/UrlTemplates.html)\n\nA Compelling Example:\n\n```fsharp\nopen UrlTemplates.RouteMatcher\n\nlet template = \"/api/v1/profiles/:id\u003cint\u003e?optionalKey\u003cguid\u003e\u0026requiredKey!#hash\"\nlet url = \"/api/v1/profiles/2345?requiredKey=2#hash\"\n\nmatch RouteMatcher.matchStrings template url with\n| Ok (urlTemplate, urlInfo, urlMatch) -\u003e\n  let { Segments = foundParams; Query = queryParams; Hash = foundHash } = urlTemplate\n  // foundParams\n  // [ Plain \"\"; Plain \"api\"; Plain \"v1\"; Plain \"profiles\"; Param (\"id\", \"2345\");]\n  // query\n  // [Optional \"optionalKeyu\", Guid; Required \"requiredKey\", Int]\n  // hash\n  // \"hash\"\n\n\n  let { Params = urlParams; Query = query; Hash = hash } = urlInfo\n  // urlParams\n  // [ \"\"; \"api\"; \"v1\"; \"profiles\"; \"2345\" ]\n  // query\n  // [ \"optionalKey\", String ValueNone; \"requiredKey\", String ValueSome \"2\"]\n  // hash\n  // ValueSome \"hash\"\n\n  let { Params = foundParams; QueryParams = queryParams; Hash = foundHash } = urlMatch\n  // foundParams\n  // { { \"id\", box 2345 } }\n  // queryParams\n  // { { \"requiredKey\", box \"2\" } }\n  // foundHash\n  // ValueSome \"hash\"\n\n| Error errors -\u003e\n  for e in errors do\n    printfn $\"%A{e}\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangelmunoz%2Fnavs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangelmunoz%2Fnavs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangelmunoz%2Fnavs/lists"}