Search⌘ K
AI Features

The LiveView Lifecycle

Explore the LiveView lifecycle including how Phoenix.LiveView.Socket structs manage state, how LiveView routes trigger mount and render functions, and how WebSocket connections enable real-time event handling and page updates.

Before we build our first LiveView, let’s take a deeper dive into the LiveView lifecycle. We’ll go through how LiveView manages the state of your single-page app in a data structure called a socket, as well as how LiveView starts up, renders the page for the user, and responds to events. Once we understand the LiveView lifecycle, we’ll be ready to build out this lifecycle and use it to manage the state of our own LiveViews.

We’ll begin by examining how LiveView represents the state via Phoenix.LiveView.Socket structs. Understanding how the socket struct is constructed and updated will give us the tools we need to establish and change the state of our LiveViews.

Holding

...