Is there a way to live_redirect from the liveview and not a link in the template?

When you click a link generated with live_redirect, it does a soft redirect without going through all of the pipelines defined in your router. Is there a way to do this style of liveview redirect from an event handler outside the template?

No the whole point of live_redirect instead of a good old fashioned link is to keep the websocket open, which means skipping the router stack. Can you elaborate on your use case for trying to have the router code run every time?

are you looking for push_redirect/2?

https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#push_redirect/2

2 Likes

That’s exactly what I was looking for. Thank you

1 Like