Livewire: Use cases for Livewire? Can it be used for SSR-rendered apps with Laravel

Created on 25 Jul 2019  路  4Comments  路  Source: livewire/livewire

Thanks for this repo @calebporzio!

This isn't a bug or feature request, but more of a question after having seen all the videos at https://calebporzio.com/a-bunch-of-cool-new-things-in-laravel-livewire/ and after going through the quickstart guide (Which works wonderfully well, btw).

  1. When is it appropriate to use Livewire over Vue? Obviously, Livewire makes multiple Ajax requests to the server, so it's heavy on the server.
  2. For SSR-rendered apps using Laravel + Nuxt.js, where does / can Livewire fit in? Can Livewire replace Nuxt and something like Inertiajs?
    Thoughts appreciated!

Most helpful comment

@calebporzio thanks and that would be great...imagine a side-by-side like you did in your talk here: https://www.youtube.com/watch?v=uQO4Xh1gMpY
except in code with a real, functional set of examples. If you want to really increase livewire's adoption, think about this.

The main use-cases I can think of / would make sense to me are:

  1. SSR and how vue / js cant handle it easily
  2. In what scenarios livewire is better than inertiajs
  3. how and when "Regular" ajax is painful or bad
  4. When livewire is bad (and too much load on the server), like for example sending an ajax request with every keystroke / pure js-only animations etc

The more people can see the big picture and play with livewire in the real world, the easier it will be on adoption.

All 4 comments

My Thoughts on this:

I think what makes Livewere different is that, you can use Laravel's helpers such as ( route(), trans() ..etc) as you always do in a traditional way. and you don't need to ever worry about JS as you used to.

For example: In Inertiajs or any SPA you need to convert your routes and languages files then you create an equivalent functions for route() and trans(). and you need to find a way to handle authorizations in JS .. and alot of other things.

Livewere makes you focus in your application, you don't need to worry about JS. Also you can test your application from E2E which is a mind blowing.

so it's heavy on the server

When you use Livewere that doesn't mean you handle everything using it. Animations and UI interactions better to be in Javascript.

A good rule of thumb is: any JavaScript components that rely on ajax for server communication, will be better off as Livewire components. There's lots of other good use cases, but this gives you a basic idea of where to start.

@rakk7 agreed and these points are largely good. I guess what follows is it would be really helpful to see en example Laravel app using Livewire that:

  • does SSR and (basic) Auth (using Livewire, not Laravel's make:auth). Auth is always painful - right now, using Nuxt (or even a Vue layer for SSR) requires one to write APIs.
  • integrates / plays well with Vue, and relies on Vue for a (small) client or animation-heavy, js-only piece
    Not sure what @calebporzio has in mind but if such an example app can be made available, it would easily demonstrate the benefits of Livewire over something like Nuxt (or even a Vue layer)->Laravel

Good points @connecteev, and thanks for weighing in @rakk7.

I plan to create something like that example app you're talking about in the future when development on the core settles down a little bit. It would be too annoying to have to maintain ATM. But hang in there!

@calebporzio thanks and that would be great...imagine a side-by-side like you did in your talk here: https://www.youtube.com/watch?v=uQO4Xh1gMpY
except in code with a real, functional set of examples. If you want to really increase livewire's adoption, think about this.

The main use-cases I can think of / would make sense to me are:

  1. SSR and how vue / js cant handle it easily
  2. In what scenarios livewire is better than inertiajs
  3. how and when "Regular" ajax is painful or bad
  4. When livewire is bad (and too much load on the server), like for example sending an ajax request with every keystroke / pure js-only animations etc

The more people can see the big picture and play with livewire in the real world, the easier it will be on adoption.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bardh7 picture bardh7  路  3Comments

basepack picture basepack  路  3Comments

cao-minh-duc picture cao-minh-duc  路  4Comments

ChrisJohnson-83 picture ChrisJohnson-83  路  4Comments

roni-estein picture roni-estein  路  3Comments