andrea

andrea

Can Phoenix LiveView be used in multi-page applications or does it have to be a SPA?

Can Phoenix LiveView be used in multi-page applications, unlike React/Vue/Blazor which seems to be targeted for SPA?

Most Liked

davearonson

davearonson

I don’t see any reason why not. After all, you can always set a link to go to a fresh page, whether that one has LiveView on it or not.

malloryerik

malloryerik

Yeah, LiveView webapps are kind of like anti-SPAs. You can find dozens of descriptions like this but here goes: Phoenix apps with LiveView pages are multi-page apps where some pages are regular http pages and some are LiveView pages, and the router, back buttons, urls and so on all work just like normal. If you want to only use LiveView pages in a Phoenix app that’s possible, though I think that typically at least login pages will be http.

The difference between traditional http pages and LiveView pages is that instead of an http connection which connects, sends html and data transfers and immediately disconnects, LiveView pages use a websocket connection which remains open, more like a telephone connection as an example, and push html and data changes on that page without reconnecting. (Normal Phoenix http pages are also great at establishing websocket connections, but aren’t designed to automatically send html changes over the wire.)

When you navigate from one LiveView page to another in the same app you’ll do it using the router and a new connection will be established, quite normal and delightfully boring. You can also have LiveView components inside of your LiveView pages, so basically LiveViews nested inside of other LiveViews, kind of SPA-ish but simpler.

Last, nothing stops you from using Vue, React, Svelte and so on inside of an app that has LiveViews, and even inside of LiveViews themselves (not saying it’s a necessarily a good idea). Here’s a library to help with using React components directly inside of LiveViews:

Where Next?

Popular Backend topics Top

Jsdr3398
I’m trying to create a router where everything is in a collection of routes (similar to how I do my routes in expressjs). But it doesn’t ...
New
joshi
Hey everybody! I’m working on the project that includes import of Oracle data to PostgreSQL. That data comes as Oracle export (expdp) fi...
New
New
Jsdr3398
I’ve been working on and rewriting my messaging platform several times for the past two years. With Discords new rebranding, it has reall...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
TwistingTwists
Hello Folks, I am a novice developer from India. Intending to learn Elixir and web apps (phoenix framework). What are things that I MUS...
New
Fl4m3Ph03n1x
Background PS: the following situation describes an hypothetical scenario, where I own a company that sells things to customers. I have ...
New
New
Fl4m3Ph03n1x
Background I have a release file inside a tarball. However I want the final release to have some additional files and to move things aro...
New
Shiny
Hey community, this is my first post here so I will try to be as concise as possible and I appreciate any feedback. I’ve been writing Ro...
New

Other popular topics Top

Devtalk
Reading something? Working on something? Planning something? Changing jobs even!? If you’re up for sharing, please let us know what you’...
1033 17470 383
New
AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
New
AstonJ
Or looking forward to? :nerd_face:
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New
AstonJ
This is cool! DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON We just witnessed something incredible: the largest open-s...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New