Phoenix.LiveView.get_connect_params
You're seeing just the function
get_connect_params
, go back to Phoenix.LiveView module for more information.
Accesses the connect params sent by the client for use on connected mount.
Connect params are only sent when the client connects to the server and
only remain available during mount. nil
is returned when called in a
disconnected state and a RuntimeError
is raised if called after mount.
Reserved params
The following params have special meaning in LiveView:
"_csrf_token"
- the CSRF Token which must be explicitly set by the user when connecting"_mounts"
- the number of times the current LiveView is mounted. It is 0 on first mount, then increases on each reconnect. It resets when navigating away from the current LiveView or on errors"_track_static"
- set automatically with a list of all href/src from tags with thephx-track-static
annotation in them. If there are no such tags, nothing is sent
Examples
def mount(_params, _session, socket) do
{:ok, assign(socket, width: get_connect_params(socket)["width"] || @width)}
end