{"id":13760413,"url":"https://github.com/oconn/re-frame-routing","last_synced_at":"2026-02-21T01:31:24.465Z","repository":{"id":62433869,"uuid":"110035478","full_name":"oconn/re-frame-routing","owner":"oconn","description":"ClojureScript (re-frame) library that manages routing and route state.","archived":false,"fork":false,"pushed_at":"2023-10-27T18:29:27.000Z","size":65,"stargazers_count":17,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-22T01:58:41.274Z","etag":null,"topics":["clojurescript","clojurescript-library","re-frame"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oconn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2017-11-08T22:01:13.000Z","updated_at":"2023-01-04T14:38:53.000Z","dependencies_parsed_at":"2024-01-15T03:59:50.256Z","dependency_job_id":null,"html_url":"https://github.com/oconn/re-frame-routing","commit_stats":{"total_commits":23,"total_committers":3,"mean_commits":7.666666666666667,"dds":"0.34782608695652173","last_synced_commit":"6da0284b2d201788df4f032cdce3d10196952885"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/oconn/re-frame-routing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oconn%2Fre-frame-routing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oconn%2Fre-frame-routing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oconn%2Fre-frame-routing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oconn%2Fre-frame-routing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oconn","download_url":"https://codeload.github.com/oconn/re-frame-routing/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oconn%2Fre-frame-routing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29670124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T00:11:43.526Z","status":"ssl_error","status_checked_at":"2026-02-20T23:52:33.807Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["clojurescript","clojurescript-library","re-frame"],"created_at":"2024-08-03T13:01:09.790Z","updated_at":"2026-02-21T01:31:24.438Z","avatar_url":"https://github.com/oconn.png","language":"Clojure","funding_links":[],"categories":["Clojure"],"sub_categories":[],"readme":"# re-frame-routing\n\nClojureScript (re-frame) library that manages routing and route state.\n\n**re-frame-routing** is built on top of [bidi](https://github.com/juxt/bidi) and persists route state to [re-frame's](https://github.com/Day8/re-frame) app state. Registering *re-frame-routing* to an existing re-frame application is ease.\n\n\n### Step 1: Install\n\n[![Clojars Project](https://img.shields.io/clojars/v/oconn/re-frame-routing.svg)](https://clojars.org/oconn/re-frame-routing)\n\n[![CircleCI](https://circleci.com/gh/oconn/re-frame-routing/tree/master.svg?style=shield)](https://circleci.com/gh/oconn/re-frame-routing/tree/master)\n\n### Step 2: Import Events\n\n```cljs\n(ns app.events.core\n  (:require [re-frame-routing.core :as rfr]\n\n            [app.router.core :as router]))\n\n(rfr/register-events {:routes router/routes})\n```\n\n### Step 3: Import Subscriptions\n\n```cljs\n(ns app.subscriptions.core\n  (:require [re-frame-routing.core :as rfr]))\n\n(rfr/register-subscriptions)\n```\n\n## Route Middleware\n\n*(Note this API is subject to change in future releases)*\n\n### Pre Dom Render Loading \n\nSometimes it's nice to perform work when a route is loading, maybe even prevent the route's view from displaying until that work is done, or even redirect if a user does not have access to view the route. These are good use cases for route-middleware.\n\nTo add route-middleware to a route, first create the route-middleware function\n\n```cljs\n(def route-middleware\n  (rfr/create-route-middleware {:loading-view loading/render}))\n```\n\n`loading-view` is a reagent component that will display while your route is loading.\n\nNow let's say you have a sign-in page, but only unauthenticated users should be able to view it. Here is you sign-in route with no middleware\n\n```cljs\n(defmethod containers :sign-in []\n  [sign-in/render])\n```\n\nAnd now we add some middleware\n\n```cljs\n(defmethod containers :sign-in []\n  [(route-middleware\n    sign-in/render\n    [redirect-authenticated])])\n```\n\nWithout diving into `redirect-authenticated` quite yet, let's first look at our `route-middleware` function. It takes in a view component and a vector of middleware functions (executed from left to right). The result after all functions have executed is the view. The view will receive path and query params as arguments.\n\nNext let's look at `redirect-authenticated`\n\n```cljs\n(defn redirect-authenticated\n  \"Redirects authenticated users to the authenticated home page\"\n  [{:keys [route-query route-params] :as ctx}]\n  (let [is-authenticated (re-frame/subscribe [:user/is-authenticated?])]\n\n    (when (true? @is-authenticated)\n      (re-frame/dispatch [:router/nav-to \"/authenticated-home\"]))\n\n    (if (true? @is-authenticated)\n      (assoc ctx :is-loading true)\n      ctx)))\n```\n\nMiddleware functions will be passed a context object and are expected to return a context object. To prevent the execution of the next middleware function in the chain, toggle the `is-loading` property on the middleware context object to `true`.\n\n\n### Route Coercion\n\nGiven data sent to the servers and to the component originates from information synced in the url (path and query params), it's ideal to have a way to share concerns over configuration (coercion and defaults).\nThe library supports that concern by allowing you to supply an `routes-enirched` tree where leafs can be supplied a configuration instead of a keyword. e.g\n\n```\n{:query {:site {:coercion int?}\n         :role {:coercion int?}\n         :learner {:coercion #{\"least-ready\" \"most-ready\" \"highest-mindset\" \"lowest-mindset\"}\n                   :default \"least-ready\"}\n         :current-page {:coercion int?\n                :default 0}}}\n```\n\nthis will then provide a route-parameters map to the component. e.g\n\n```\n{:route-parameters {:role 1 :learner \"least-ready\" :site 2 :current-page 0}}\n```\n\nThis functionality is then handled by [spec-tools](https://github.com/metosin/spec-tools). Overall this is a less feature rich version of what's provided by [reitit](https://github.com/metosin/reitit/blob/master/doc/coercion/clojure_spec_coercion.md). \n\n\n## Development\n\nRun ` clj -M:shadow-cljs watch app` to and get a watched build. See Shadow cljs docs for more.\n\n## License\n\nCopyright © 2018 Matt O'Connell\n\nDistributed under the Eclipse Public License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foconn%2Fre-frame-routing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foconn%2Fre-frame-routing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foconn%2Fre-frame-routing/lists"}