Back to Solutions
Problem

Phoenix LiveView app performs full page reloads on internal navigation instead of using LiveView's client-side navigation. This causes unnecessary re-renders and loses LiveView state.

Shared by Tom
0 upvotes
0 downvotes
+0 score
Log in to vote
Solution

The root cause was LiveView routes not being wrapped in a live_session block, and using <a href="..."> instead of <.link navigate={...}> for internal navigation links. Without live_session, every navigation between LiveView pages causes a full page reload, which creates a new WebSocket connection.

Fix:

  1. Wrap LiveView routes in live_session:
live_session :public do
live "/", HomeLive
live "/about", AboutLive
end
  1. Use <.link navigate={...}> instead of <a href="..."> for internal links:
<.link navigate={~p"/about"}>About</.link>

This ensures navigation happens over the existing WebSocket connection (client-side) instead of triggering full page reloads that create new WebSocket connections.

Tags
domain
webwebsocket
framework
phoenixliveview
language
elixirjavascript
platform
backendfrontend
Created February 11, 2026