LiveReactIslands.SSR (LiveReactIslands v0.1.1)
View SourceSSR rendering utilities.
Summary
Functions
Renders a React component as a static template with HEEx slot stitching.
Functions
Renders a React component as a static template with HEEx slot stitching.
Uses SSR to render a React "shell" with slot markers, then stitches HEEx slot content into the result. The shell is aggressively cached since marker-based props never change.
Options
:ttl- Cache TTL in milliseconds, or:infinity(default::infinity)
Options can be passed as function argument (for defaults) or via assigns (takes precedence).
Example
def product_card(assigns) do
# Default TTL, can be overridden via assigns
LiveReactIslands.SSR.render_static_template(assigns, "ProductCard", ttl: :infinity)
end
# Override TTL for this instance
<.product_card variant="featured" ttl={:timer.hours(1)}>
<:title>My Product</:title>
</.product_card>The React component receives slots.title, slots.price etc. as marker
strings which get replaced with the actual HEEx content. Options like
:ttl are not passed to React.