How to convert a controller to LiveView?

In a controller in some places I’m currently using

curr_usr = conn.assigns[:current_user]

I want to convert a controller to LiveView.

How will I use conn.assigns[:current_user] in a LiveView? Or what will I use instead of it?

If I’m not mistaken, it would be available in the mount/3 second parameter (session). Take a look Phoenix.LiveView — Phoenix LiveView v0.17.11

1 Like