Helpers for rendering LiveViews from a controller.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/phoenixframework/phoenix_live_view/llms.txt
Use this file to discover all available pages before exploring further.
Overview
ThePhoenix.LiveView.Controller module provides functions for rendering LiveViews from within traditional Phoenix controllers. This is useful when you need to render a LiveView as part of a regular controller action rather than through the router.
Functions
live_render/3
Renders a live view from a Plug request and sends an HTML response from within a controller.The connection struct from the controller
The LiveView module to render
Options for rendering the LiveView. See
Phoenix.Component.live_render/3 for all supported options.Common options include::session- Session data to pass to the LiveView’s mount callback:container- HTML container configuration:id- The DOM ID for the LiveView
The connection with the rendered LiveView response
@live_module assign with the value of the LiveView being rendered.
Examples
Basic usage:Behavior
The function handles different scenarios:- Successful render: Returns the rendered HTML content with proper assigns
- Redirect: If the LiveView redirects during mount, follows the redirect appropriately
- Live redirect: Handles live navigation redirects with flash messages