How to return the current url from a liveview component?

I have a header component that wrap all logged pages, and I’m trying to append an #id at the end of the current url when clicking a button, in order to toggle a modal.
References I saw online share mostly solutions using @conn, that is not available in liveview.
Thanks for any guidance :slight_smile:

1 Like

The handle_params/3 callback gets the current uri as the second parameter. It’s invoked whenever the uri changes. You could implement that callback and assign the current_uri to the socket. You’ll have to pass that assign to your component in order to make sure it gets updated.

2 Likes