Reverting from LiveView to static page

I created a Phoenix app, passing --live to mix phx.new because I thought I would use the features of LiveView. However, after spending some time building the app, it doesn’t seem like I will use those LiveView features after all.

  • Is there an “official” way to revert the project from a LiveView page to a static page? I figure I could change the route in router.ex to not use the “live” macro, but will this alone have unintended consequences?
  • Is there any benefit to doing this anyway? e.g. less resource usage

Thanks in advance.

Hi,

Is there an “official” way to revert the project from a LiveView page to a static page?

I don’t think so.

I figure I could change the route in router.ex to not use the “live” macro, but will this alone have unintended consequences?

You might also want to “clean” lib/your_app_web.ex but it should be sufficient as long as you keep LV as dependency (even implicit, it will be pulled by phoenix_live_dashboard if you use it).

EDIT : there is also the endpoint to check for the socket/3 calls

Is there any benefit to doing this anyway?

You could get rid of the :phoenix_live_view dependency (in deps/0 of your mix.exs file) except if you use phoenix_live_dashboard (reduce time compilation, less files to deploy, …)

1 Like

No. There is no difference at all for the actual runtime of the application, and you probably want phoenix_live_dashboard anyway which means you need phoenix_live_view as a dependency anyway.

1 Like