{"id":23626264,"url":"https://github.com/yetanalytics/re-route","last_synced_at":"2025-08-17T03:40:41.647Z","repository":{"id":242943767,"uuid":"796851819","full_name":"yetanalytics/re-route","owner":"yetanalytics","description":"Routing wrapper library for SPAs based on re-frame.","archived":false,"fork":false,"pushed_at":"2024-10-23T14:32:31.000Z","size":599,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-07T11:56:05.556Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://clojars.org/com.yetanalytics/re-route","language":"Clojure","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/yetanalytics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2024-05-06T18:41:15.000Z","updated_at":"2024-10-23T14:33:44.000Z","dependencies_parsed_at":"2024-10-23T16:32:33.232Z","dependency_job_id":null,"html_url":"https://github.com/yetanalytics/re-route","commit_stats":null,"previous_names":["yetanalytics/re-route"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/yetanalytics/re-route","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yetanalytics%2Fre-route","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yetanalytics%2Fre-route/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yetanalytics%2Fre-route/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yetanalytics%2Fre-route/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yetanalytics","download_url":"https://codeload.github.com/yetanalytics/re-route/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yetanalytics%2Fre-route/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270803531,"owners_count":24648688,"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","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-12-27T22:52:38.613Z","updated_at":"2025-08-17T03:40:41.620Z","avatar_url":"https://github.com/yetanalytics.png","language":"Clojure","readme":"# re-route\n\n[![Clojars Project](https://img.shields.io/clojars/v/com.yetanalytics/re-route.svg)](https://clojars.org/com.yetanalytics/re-route)\n\nRouting wrapper library for SPAs based on [re-frame](https://github.com/day8/re-frame) and [reitit](https://github.com/metosin/reitit).\n\nIn addition to standard navigation functionality, this library comes with built-in functionality for navigation prevention, e.g. to warn the user of unsaved input changes.\n\n## Installation\n\nTo use re-route as a dependency in your ClojureScript project, add the following to your `deps.edn` file:\n\n```clojure\n{ com.yetanalytics/re-route {:mvn/version \"0.1.0\"} }\n```\n\nFor information on the latest version, as well as the changelog for previous versions, see the [Releases](https://github.com/yetanalytics/re-route/releases) page.\n\n**NOTE:** re-route assumes that your browser supports the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API).\n\n## API\n\nAll API functions are located in the `com.yetanalytics.re-route` namespace, which we will alias to `re-route`.\n\n### Effect Handlers\n\n#### `[::re-route/init routes default-route prevent-nav-opts]`\n\nStarts a reitit router and initializes re-route's values in the re-frame app-db.\n\n`routes` is a reitit-compatible vector of route maps; a standard route map looks something like:\n```clojure\n{:name        :route-name\n :view        (fn [args] ...)\n :parameters  { ... }\n :controllers [{:start (fn [params] ...)\n                :stop  (fn [params] ...)}]}\n```\nwhere `:controllers` contains the `:start` and `:stop` functions that are called when entering and leaving the route, respectively. `:view` is a property unique to re-route that specifies a Reagent render function.\n\n`default-route` is the `:name` of the fallback route to be served instead of a route that is not found in the router. This is usually for \"Not Found\" pages.\n\n`prevent-nav-opts` is an options map for navigation prevention:\n- `:enabled?` determines if nav prevention is enabled or not. If `false`, then the `::re-route/set-prevent-nav` effect handler has no effect. Default `true`.\n- `:back-button?` determines whether nav prevention is enabled for browser back button clicks (or other changes to the browser history stack). Default `false`, as enabling this causes weird effects with the browser history, due to limitations of the History API.\n- `:default-text` sets the default text for confirm dialogs. By default this is \"You have unsaved changes, are you sure?\"\n\n#### `[::re-route/navigate route-name path-params query-params fragment]`\n\nNavigate to a new route with these parameters, and calls [`.pushState`](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState) on the history stack.\n\n#### `[::re-route/navigate-replace route-name path-params query-params fragment]`\n\nSame as `::re-route/navigate`, but calls [`.replaceState`](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState) on the history stack instead. This will, unlike `.pushState`, _not_ push the current page onto the history stack.\n\n#### `[::re-route/set-prevent-nav ?text]`\n\nSets navigation prevention, which will cause navigation away from the current page to trigger a confirm dialog. `?text` sets the confirm dialog text (for non-[`beforeunload`](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event) dialogs).\n\n#### `[::re-route/unset-prevent-nav]`\n\nUnsets navigation prevention, allowing navigation to proceed as normal again.\n\n#### `[::re-route/on-start]` and `[::re-route/on-stop]`\n\nCalls the `on-start` and `on-stop` multimethods, respectively. These multimethods are an alternative to defining the handlers directly; in other words, instead of writing this:\n\n```clojure\n{:start (fn [params] (dispatch [:start-my-page params]))}\n```\n\none can write this:\n\n```clojure\n{:start (fn [params] (dispatch [::re-route/on-start :my-page params]))}\n\n(defmethod re-route/on-start :my-page [\u0026 params] ...)\n```\n\nThe `add-controllers` function takes a `[path route-data]` pair and automatically applies a `:controllers` map with a pair of `::re-route/on-start` and `::re-route/on-stop` dispatch functions.\n\n### Subscriptions\n\n#### `[::re-route/href route-name path-params query-params fragment]`\n\nCreates a link from the parameters to be used in anchor tags. Clicking on the link is the same as navigation via `::re-route/navigate` for the same route and parameters.\n\n#### `[::re-route/prevent-nav]`\n\nReturns the current `prevent-nav` map.\n\n#### `[::re-route/route]`\n\nReturns the current route map.\n\n#### `[::re-route/route-name]`\n\nReturns the name of the current route.\n\n#### `[::re-route/route-view]`\n\nReturns the `:view` render function of the current route.\n\n#### `[::re-route/path-params]`, `[::re-route/query-params]`, `[::re-route/fragment]`\n\nReturns the appropriate parameters of the current route.\n\n## Run Demo\n\nThis library comes with a demo that demonstrates the functionality of re-route. This can be run via Figwheel or can be compiled and run on an nginx webserver.\n\nTo run via Figwheel, run `make dev`.\n\nTo compile the demo webpage, run `make demo-bundle`, which will create a `target/demo_bundle` directory. Then to run the webpage on an nginx Docker image, `cd` to the `target/demo_bundle` directory, then run:\n```\ndocker build -t re-route-nginx-image .\n```\nfollowed by\n```\ndocker run --name re-route-nginx-container -p 9500:80 re-route-nginx-image\n```\nwhich will serve the webpage on `localhost:9500`.\n\n### Screenshots\n\nOpening the webpage at `localhost:9500` will display the home page:\n![home page](doc/images/home.png)\n\nClick on \"Link to Page One\" to view Page One:\n![view page](doc/images/view.png)\n\nClick on \"Edit\" to edit the contents of Page One:\n![edit page](doc/images/edit_1.png)\n\nEditing the text, then clicking on \"Return Link\" will display a navigation prevention popup:\n![prevent navigation](doc/images/edit_2.png)\n\nGoing to an external link (e.g. \"Link to Yet Analytics Website\") will display a different dialog (corresponding to a [`beforeunload`](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event) event):\n![prevent link navigation](doc/images/edit_3.png)\n\n## Credits\n\n- [re-frame](https://github.com/day8/re-frame) and [reitit](https://github.com/metosin/reitit) serve as the foundations that re-route was built on.\n- [kee-frame](https://github.com/ingesolvoll/kee-frame) is another re-route and reitit-based navigation library that was developed independently (we were not even aware of its existence when developing re-route).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyetanalytics%2Fre-route","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyetanalytics%2Fre-route","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyetanalytics%2Fre-route/lists"}