View Source Inertia.SSR.Adapter behaviour (Inertia v3.1.0)
Behaviour for Inertia SSR adapters.
An adapter is responsible for taking an Inertia page payload and producing
the rendered head and body strings. The default adapter
(Inertia.SSR.NodeJSAdapter) calls into a Node.js process pool, but
alternative runtimes (e.g. Bun, a Vite dev server) can be plugged in by
implementing this behaviour and passing the module as the :ssr_adapter
option to Inertia.SSR.
Callbacks
init/1— build adapter configuration from the supervisor's options. Called once at startup. The returned term is passed back tochildren/1andcall/2on every render.children/1— return any child specs the adapter needs added to theInertia.SSRsupervision tree (e.g. a Node.js worker pool).call/2— render a page payload. Called from the request process, so avoid serializing work through a singleton process.
Summary
Types
@type adapter_config() :: term()
@type page() :: %{ :component => String.t(), :props => map(), :url => String.t(), :flash => map(), optional(:version) => String.t(), optional(:encryptHistory) => boolean(), optional(:clearHistory) => boolean(), optional(:mergeProps) => [String.t()], optional(:prependProps) => [String.t()], optional(:deepMergeProps) => [String.t()], optional(:matchPropsOn) => [String.t()], optional(:deferredProps) => map(), optional(:onceProps) => map(), optional(:scrollProps) => map(), optional(:rescuedProps) => [String.t()], optional(:sharedProps) => [String.t()], optional(:preserveFragment) => boolean() }
Callbacks
@callback call(page(), adapter_config()) :: ssr_result()
@callback children(adapter_config()) :: [{module(), keyword()}]
@callback init(opts :: keyword()) :: adapter_config()