inertia.core
Public API. Handlers return render or location responses, and wrap-inertia turns them into HTML (first visit) or JSON (Inertia visits).
always
(always v)Sent on every response, including partial reloads that did not ask for it.
deep-merge
(deep-merge v)(deep-merge v {:keys [match-on]})The client deep-merges this prop into its current value. :match-on paths are relative to the prop, e.g. “data.id”.
defer
(defer f)(defer f group)Skipped on full visits and listed in the page’s deferredProps under group. The client fetches each group with an automatic partial reload after the page mounts.
location
(location url)A redirect the client follows with a full page load, e.g. to an external site. Inertia requests get 409 + X-Inertia-Location; others a plain 302.
merge
(merge v)(merge v {:keys [match-on]})The client appends this prop to its current value instead of replacing it. :match-on names the field (or fields) used to replace existing items.
once
(once f)(once f {:keys [key expires-at fresh?]})Resolved once and remembered by the client; later full visits skip it while the client still holds an unexpired copy.
Options: :key client cache key (defaults to the prop name) :expires-at epoch millis, or nil for no expiry :fresh? always resolve and replace the client’s copy
optional
(optional f)Skipped on full visits and not announced. Sent only when a partial reload asks for it, e.g. router.reload({only: ['permissions']}).
render
(render component)(render component props)(render component props options)A response that renders component with props.
options: :status HTTP status, default 200 :encrypt-history encrypt this page’s history entry :clear-history rotate the history encryption key :preserve-fragment keep the URL fragment after a redirect to this page :ssr true or false to use or skip SSR for this response, overriding the middleware’s {:ssr {:default ..}}; has no effect when the middleware has no :ssr config
scroll
(scroll f)(scroll f {:keys [data-key meta]})An infinite-scroll prop. The client appends items found under :data-key (default “data”) and uses the scroll metadata to request more pages.
:meta is a map, or a fn of the resolved value, returning any of :page-name, :previous-page, :next-page, :current-page.
wrap-inertia
(wrap-inertia handler)(wrap-inertia handler opts)Ring middleware that serves Inertia v3 responses.
opts: :version asset version, a string or 0-arity fn :template (fn [{:keys head body page} req] html-string); body holds the page script and root element, head any SSR head tags :share (fn req props-map) of props shared by every page :errors (fn req errors-map); default reads (:errors (:flash req)) :flash (fn req flash-map); default none :id root element id, default “app” :encrypt-history? encrypt history for every page :json-encode (fn x json-string); default jsonista :ssr nil, or {:url .. :timeout-ms .. :on-error (fn ex) :default ..} :url is the full render endpoint, default http://127.0.0.1:13714/render. :default (true) says whether pages use SSR when their render call sets no :ssr option; set it false and pass {:ssr true} to render to opt pages in.