{"id":13513691,"url":"https://github.com/prestancedesign/inertia-clojure","last_synced_at":"2025-08-21T04:31:06.932Z","repository":{"id":46747171,"uuid":"359530098","full_name":"prestancedesign/inertia-clojure","owner":"prestancedesign","description":"A Clojure adapter for Inertia.js ","archived":false,"fork":false,"pushed_at":"2022-07-30T07:08:45.000Z","size":81,"stargazers_count":97,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-12-17T06:58:21.279Z","etag":null,"topics":["clojure","compojure","inertia-clojure","inertiajs","inertiajs-adapter","middleware","react","reagent","reitit","ring"],"latest_commit_sha":null,"homepage":"https://inertia.prestance-design.com/","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/prestancedesign.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}},"created_at":"2021-04-19T16:41:11.000Z","updated_at":"2024-11-01T11:08:54.000Z","dependencies_parsed_at":"2022-08-30T08:31:50.366Z","dependency_job_id":null,"html_url":"https://github.com/prestancedesign/inertia-clojure","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prestancedesign%2Finertia-clojure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prestancedesign%2Finertia-clojure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prestancedesign%2Finertia-clojure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prestancedesign%2Finertia-clojure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prestancedesign","download_url":"https://codeload.github.com/prestancedesign/inertia-clojure/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230487844,"owners_count":18233865,"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":["clojure","compojure","inertia-clojure","inertiajs","inertiajs-adapter","middleware","react","reagent","reitit","ring"],"created_at":"2024-08-01T05:00:35.652Z","updated_at":"2024-12-19T19:08:57.827Z","avatar_url":"https://github.com/prestancedesign.png","language":"Clojure","funding_links":[],"categories":["Clojure","Adapters"],"sub_categories":["Server-side"],"readme":"# Inertia Clojure\n\nClojure Middleware adapter for [Inertia.js](https://inertiajs.com/) to build single-page apps, without building an API.\n\nThe latest versions on Clojars\n\n[![Clojars Project](https://clojars.org/com.github.prestancedesign/inertia-clojure/latest-version.svg)](https://clojars.org/com.github.prestancedesign/inertia-clojure)\n\n## Introduction\n\nInertia is a new approach to building classic server-driven web apps. From their own web page:\n\n\u003e Inertia allows you to create fully client-side rendered, single-page apps, without much of the complexity that comes with modern SPAs. It does this by leveraging existing server-side frameworks.\n\nInertia requires an adapter for each backend framework.\n\nFor Clojure there is no de facto web framework, so I went with a [Ring](https://github.com/ring-clojure/ring) middleware who shape up the [`request`](https://github.com/ring-clojure/ring/wiki/Concepts#requests) and [`response`](https://github.com/ring-clojure/ring/wiki/Concepts#responses) to meet the Inertia.js [protocol](https://inertiajs.com/the-protocol).\n\n## Install\n\nFor `deps.edn`:\n\n```clojure\ncom.github.prestancedesign/inertia-clojure {:mvn/version \"0.2.5\"}\n```\n\nFor `project.clj`:\n\n```clojure\n[com.github.prestancedesign/inertia-clojure \"0.2.5\"]\n```\n\n## Usage\n\nInertia-clojure contains a standard Ring middleware `wrap-inertia` that you can use with routing libraries like [Reitit](https://github.com/metosin/reitit), [Compojure](https://github.com/weavejester/compojure), etc.\nThe middleware must be the last item in your web middleware chain.\n\nIt expects 3 arguments:\n\n* the app handler\n* template: a function that recieves data-page arg - a correctly encoded string of the Inertia page object. The function should return an HTML string, so the template lib is up to you.\n* version: your current asset version https://inertiajs.com/asset-versioning\n\nNote: In your HTML template function make sure to always include the `data-page` string in the attribute of the HTML node you want to render your JavaScript app in.\nFor more information on how Inertia works read the protocol on the Inertia website https://inertiajs.com/the-protocol.\n\n## Example\n\n```clojure\n(require '[inertia.middleware :as inertia])\n;; ... Another required lib (compojure, httpkit, etc)\n\n(def asset-version \"1\")\n\n;; Create html template with library of your choice, here Hiccup\n(defn template [data-page]\n  (page/html5\n   [:head\n    [:meta {:charset \"utf-8\"}]\n    [:title \"Inertia + Clojure example\"]]\n   [:body\n    [:div {:id \"app\"\n           :data-page data-page}] ; The Inertia JSON page object\n    (page/include-js \"/js/app.js\")])) ; Include your Reagent, React, Vue or Svelte SPA\n\n(defroutes routes\n  (GET \"/\" [] (inertia/render :index {:title \"Hello World!\"})) ; Use the Inertia render helper to return formatted response\n  (GET \"/demo\" [] (inertia/render :demo {:title \"Clojure + Inertia\"}))\n  (route/resources \"/\"))\n\n(def app (inertia/wrap-inertia routes template asset-version)) ; Wrap your handler with the Inertia middleware\n\n(http/run-server app {:port 3000})\n```\n\n## Project examples\n\n### Full stack\n\n* [Ping CRM](https://github.com/prestancedesign/clojure-inertia-pingcrm-demo): port of the official Inertia demo to Clojure Ring, Reitit, Integrant and next.jdbc\n* [Usermanager Integrant + Reitit stack](https://github.com/prestancedesign/reagent-inertia-reitit-integrant-fullstack): Single page application in Clojure Ring, Reitit + Reagent/Inertia.js\n* [Usermanager Component + Compojure stack](https://github.com/prestancedesign/usermanager-reagent-inertia-example): Single Page App demo in Clojure, Ring, Compojure + Reagent/Inertia.js\n* [Inert - Inertia + Clojure + Svelte](https://git.sr.ht/~korven/svelte-inertia): Single Page App demo in Clojure, Reitit-Ring, Svelte/Inertia.js and Vite. You can check out the live website here - [Inert](https://inert-clj.herokuapp.com).\n\n### Server side\n\n* [Reitit / Selmer](examples/server-side/reitit-selmer): An example with Reitit routing and Selmer template lib\n* [Compojure / Hiccup](examples/server-side/compojure-hiccup): An example with Compojure routing and Hiccup for the template\n\n### Client side\n\n* [Reagent / Shadow-CLJS + Inertia.js](examples/client-side/reagent-inertiajs)\n\n## Features\n\nFeatures of the official server-side adapters are still in progress.\n\n### Todo:\n\n- [x] Shared data\n- [x] Partial reloads\n- [X] Assets versionning\n- [x] Validation error props\n- [ ] Lazy loaded props\n- [ ] Root template data\n\n## License\n\nCopyright © 2021 Michaël Salihi / Prestance\n\nDistributed under the Eclipse Public License version 1.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprestancedesign%2Finertia-clojure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprestancedesign%2Finertia-clojure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprestancedesign%2Finertia-clojure/lists"}