LiveView - any way to conditionally NOT upgrade to a live view after initial render?

I’m wondering if there is a (reasonable) way to conditionally prevent the live view lifecycle from connecting via socket?

For example, I have a small game app. If the game is over, there is no more interactivity, and so a new visit to this page has no need for the live view to do anything after the initial pass through mount/3 and handle_params/3.

Everything is controlled from the client side: You can conditionally don’t connect from the client side, or tell the client side to disconnect by pushing a event that define.

Indeed. You can control from the server whether the client will connect though, by including the LV js script or not, something like:

    current_user = current_user(assigns)
    js =
      if not is_nil(current_user) and current_user.game_state.status !=:over do

    <script defer phx-track-static crossorigin='anonymous' src='#{js}'></script>

If you have phx-click and some JS hooks that should still work without the connected socket, here’s some example code for your basic.js: bonfire_ui_common/assets/js/bonfire_basic.js at main · bonfire-networks/bonfire_ui_common · GitHub

Very cool, thanks