Build a Simple LiveView

Learn how to build a simple LiveView in Phoenix.

The Pento app’s first LiveView will be a simple game called “You’re Wrong!”. It will ask the users to guess a number and then tell them they’re wrong.

We’ll have to do three things:

  • Build a route
  • Render a page
  • Handle the events

Let’s go!

How to define the route

LiveView routes are defined in our Phoenix application’s router. First, we open up lib/pento_web/router.ex and add the live route for "/guess" like this:

Get hands-on with 1200+ tech skills courses.