Link Prefetching in LiveView, like Next.js?

I’m currently experimenting with Phoenix LiveView, and that looks really promising. As a person who has worked with .NET Blazor for a long time, LiveView isn’t something comparable to Next.js, yet. But it’s some truth about it that made me really fall in love with this framework: Simplicity.

Nevertheless, There’s one feature that is really simple to set up in some front-end web frameworks, like Next and Remix; and that is Link Prefetching. When a link becomes visible in the DOM, the browser fetches it before the user has clicked on it, so it will “Feel” snappier from the user’s perspective. Of course, only the skeleton of the page will be loaded, and things like DB fetch and other heavy stuff that we put in tag in React (and show the user a skeleton of the page instead), will not be loaded at prefetching.

My question is this: is doing such a thing possible in Phoenix LiveView?

3 Likes

Hey, I agree this would be pretty good to have in Phoenix LiveView, but because of the way LiveView works It is a non-trivial implementation with many gotchas. You can follow a discussion on the Phoenix suggestions forum section about this here:

2 Likes