How phoenix layouts work in phoenix 1.7?

I haven’t used phoenix for some time and the new layouts confuse me:

/layouts
  app.html.heex
  root.html.heex

From what I remember before, there was the live.html.heex that would be generated for liveview components, however it is not clear on how it works now, because the content from app.html.heex is rendered in dead views too.

Can someone explain how this works currently?

All the functionality, which previously required a separate live.html and app.html template was updated with functionality, which works for both codepaths (mostly flash message handling). So there’s simply no longer a need for those separte layout files.

3 Likes

So basically adding live functionality in root files is out of the question currently, or I am missing something?

Yes. Always has been. The root layout doesn’t include live things, the layout can …

2 Likes

Good details here: Live layouts — Phoenix LiveView v0.19.5

This is exactly what I was looking for, thanks!

1 Like