Use handle_params when your liveview changes state based on the URL
This little article really helped me get my head around what goes in handle_params and what goes in mount in LiveView.
The handle_params/3 callback helps use the state in the URL to drive the presentation of your LiveView. This is nice because you can share the URL with anyone and see the same LiveView state. handle_params is invoked after mount or during a live navigation event.
This is useful for things like searching and filtering. Assign the relevant values here rather than in the mount function, so you don’t have to calculate them twice..
To trigger
handle_params/3, push_patch/2 can be used server-side, whilelive_patch/2will triggerhandle_param/3through a client-side interaction.
(note that live_patch is deprecated, and is now a <.link patch={})