YouTubevideo· Jul 14, 2025· 17:29· 7,100 views on YouTube

3 Things Laravel Livewire Is NOT (But Everyone Thinks It Is)

Watch on YouTube ↗
0:00

React at a moment you like. The best moments light up here.

transcript

40 moments
  1. I'm going to tell you everything that Laravel Livewire is not. If you're new to the Laravel ecosystem or you're just curious, you've seen it at a glance and you're like, "Hey, that looks kind of cool." Most of the time you're probably wondering which one should I write?

  2. Should I write Laravel Livewire and have that be my front end or should I use something like Inertia where I can write React code or Vue code or spelt code and not have to change too much? Especially if you're coming from the JavaScript world. There's a few things to keep in mind about what Larbo Livewire is not so that you know if that might be something that you're interested in because at the end of the day it doesn't really come down to just syntax of how your particular front-end code looks. It it maybe matters a little bit but at the end of the day it really comes down to how is it supposed to work.

  3. How is it supposed to work? How are you supposed to use the tools given to you in that particular view layer, that particular front end, that particular way of writing UI? But even before we get into that, here's the sponsor for today's video. Give a shout out to the sponsor of the channel for this month. It's Bento. Now, Bento is an incredible service. To call it just a mail service, an email service is really an understatement because it's so much more.

  4. You can use it for transactional emails, for flow emails like marketing emails, but it also has a incredible amount of other products of other options that you can use to really make your app great to make your product even better. And the founder and the support for Bento is absolutely topnotch. Uh Jesse, the founder of Bento, is someone who truly cares about making things, about creating things, about making a great product. He's been doing it for a while. And so, thank you so much for Bento for sponsoring this channel this month. Let's get back into it.

  5. One of the main reasons I wanted to make this video is because I was watching this video from Theo where he talked very positively about Laravel, about Livewire and the tools that Laravel gives you in the ecosystem that surrounds Laravel.

  6. But there was something that caught my eye or I guess my ear because I was listening to it. It's easy to misunderstand what LiveWire is, what happens behind the scenes because it's inspired by two tools really or rather it's similar to two tools uh hotwire as well as live view. So hot wire in the rails ecosystem and then live view in the Phoenix ecosystem. So let's hear what Theo says and then we'll go ahead and look at what Laravel livewire is not. already.

  7. The reason I put Laravel so much higher than Rails for front end versus back end is because Laravel puts a lot of effort into making good experiences on the front end and building good bindings. Everything from Livewire, which is a phenomenal way to keep your back end and front end in sync using websockets to things like inertia that allow you to bring in React into your Laravel codebase and just server render with the right data in the right places while using good primitives for the front end.

  8. Did you catch that? He said that Laravel livewire is a websocket connection which it can be but it is not by default. So here's three things that Laravel livewire is not. So what is Livewire not? First thing number one Laravel livewire is not websockets. So it is not websockets and the key thing that I want to note here by default what that means is by default it is not websockets out of the box.

  9. It does not automatically connect your backend to your front end using websockets. What it does is HTML over the wire or Ajax would be another way of saying that because anytime that there is a request to the server, Laravel livewire sends HTML to the server and then receives HTML back and then it uses some JavaScript to do the DOM diffing where it's like, hey, this is the HTML that is fragmented and being returned. let me replace that on the front end.

  10. And so while it's not websockets by default, it can connect to websockets. And what that means is that Laravel has a websocket connection called Laravel Echo. And so it's allowed to be able to talk from the front end to the back end. Whenever anything happens on the back end, you can say, "Hey, let's send this Echo event and register that to the front end."

  11. And then Livewire allows you to pick up and kind of uh listen to any connections that is happening on the back end or any events that is happening on the back end. And LiveWire makes that incredibly seamless, incredibly easy to do. But it is not how every single form request, every single connection, every single time something changes, it is not websocket connected by default again, but that doesn't mean that it can't be. The key thing to note is that it is just HTML over the wire.

  12. When you send any kind of request, when a new form gets entered, when something changes on the front end, it is sending an HTML an Ajax request to the back end in order to then take that method, that function that was created on the back end and say, "Okay, now do something on the server." So, it is not a website connection. It is HTML over the wire.

  13. Number two, what Laravel Livewire is not is it does not replace JavaScript. Now, this is not the Rails world or the Rails ecosystem where we're trying to get away and trying to eliminate JavaScript as much as possible. Laravel Livewire just abstracts it. And so, that's the key difference that I want to make note of.

  14. While Livewire doesn't replace JavaScript, I would say that it abstracts the JavaScript. It uses AlpineJS which was uh created by the same creator of Larva Livewire, Caleb Porzio, and it takes that and just doesn't show you too much of what it is doing behind the scene because you don't really need to know what it's doing. So, AlpineJS is so synonymous with LiveWire where things like um when you're updating things on the front end, you're morphing things together.

  15. That's really just JavaScript doing it all. And so with that, LiveWire isn't meant to be offline or maybe if like uh you have JavaScript disabled, you're not meant to be able to do that within LiveWire. If you turned off JavaScript, nothing would work within LiveWire. It is meant to be using JavaScript. And there's even easy ways to kind of start using JavaScript within LiveWire.

  16. In fact, I made a video talking about some of the LiveWire updates that are pretty recent that make working with JavaScript even easier within LiveWire. You can find that right up here. But LiveWire's goal is to not replace JavaScript. It's meant to abstract the hard parts for you, the boilerplate parts for you so that you can just worry about what you're writing within your UI and then how is your UI communicating with your back end. So, what can we learn from this? uh it's not you choosing not to write JavaScript.

  17. A lot of people when I tell them hey I am writing livewire on the front end or that's my framework my UI of choice they're thinking oh you're not writing JavaScript then no it's not just simply writing HTML it's not simply just writing something like HTMX and you're completely abandoning any kind of JavaScript and even people who are using HTMX most of the time they're still reaching for something like AlpineJS for those UI changes no it's more saying hey

  18. there is a distinct difference of what is happening on the server and what is happening on the client. And some of the newer livewire updates even reflect that even more when you're thinking, okay, now I know for sure that I don't know something like a list is happening and being rendered on the server and then being displayed on the client, but then if I want to cycle through that list and I don't need to I don't need to request any new information from the server, that's best using done using JavaScript.

  19. And so I'm not going to reinvent the wheel. You don't choose not to write JavaScript. Instead, you just have this distinct separation of when am I writing server code using LiveWire, using PHP and Blade on the front end, and when am I using JavaScript or AlpineJS that is kind of just intermingled within your LiveWire code. And then number three, stick with me here because you might disagree with this, but number three is Laraveville Livewire is not new syntax.

  20. It is not a UI view layer where you're saying, "Hey, I need to learn this whole new syntax and how I'm displaying information on the client." There are some directives and so what I would call those are directives within LiveWire.

  21. Those usually happen like this wire colon and then we could say like wire uh colon model where you're saying I want to sync up a particular uh UI piece maybe like a text box I want to sync that to the server I would use something like wire model to do that and yeah that might feel a little different if you're used to using react where you are setting state within that and if you're using Vue it might feel a lot more similar but really there isn't any new syntax.

  22. You're not writing anything new unless you're not used to blade because what LiveWire is doing is it is taking the the directives, it's taking the view layer that Laravel already has built in in a templating language and it's using Laravel Blade. And so this is one of those things where to me as someone who came into the Laravel ecosystem, uh I I didn't know Blade. I didn't even know Vue.

  23. So, a lot of this wire colon stuff, it was it was kind of new to me in in that sense. I was familiar with it, but I hadn't used Vue very often. It was not my preference for that. But, Laravel Blade was a new templating language for me because I had to learn, okay, how am I looping through things with things like uh an at symbol to say for each and then I'm looping through it there. The templating part is not Livewire.

  24. Livewire does not dictate your template. Instead, it enhances the template that is already built in with Laravel Blade. So, it's not a new syntax in the sense that if you're coming into Laravel and you already used Blade uh or actually are familiar with Blade, it is not something that sits in addition to that.

  25. It sits on top of it. And so this is one that u a lot of people especially who are new to the Laravel world who are coming from this JavaScript world like myself a couple of years ago they might think hey this is a whole new UI syntax

  26. to learn but for the most part you're probably familiar with new uh templating languages you probably use them in a specific part even if you are using React there probably is specific parts of maybe a meta framework or even like an email framework that you're using where you do have to use a different templating system. And to me, it's not that different. It's not really a new syntax. It is just enhancing the syntax that is already kind of built in to Laravel.

  27. It is a server rendered syntax that then adds these uh live pieces of components, these JavaScript abstractions baked in to the server rendered syntax. So what can we learn from this? I think we can learn that it's not meant to reinvent uh the wheel.

  28. And what does that mean? I think that a lot of times people think when it comes to Laravel live wire that it's hey, this is something completely new. It's something that I'm not used to. Why would I learn that when I could just take my knowledge of React, my knowledge of Vue, fill in the blank, and then just start building within that. And of course, you can do that. You can do whatever you want. I'm not the boss of you. I can't just tell you, hey, you need to do this and you have to listen to me.

  29. The reason why I'm advocating for LiveWire and more just uh letting you know what LiveWire is not so that you can have this knowledge of what LiveWire actually is, it is not meant to be an event deal. It's meant to give you these abstractions to easily do the things that you would mostly do for 99% plus of any of your applications. Let me show you the website.

  30. For example, just being able to have a server rendered search that you are actually fetching information from the database and displaying it on the page. You would think that that would be a fairly complex thing when it comes down to it. Especially if you're thinking, hey, I need to actually search the database for this. I need to write an API for this.

  31. Yes, you would have to do that within any sort of uh a JavaScript or like maybe a MVC type layer, but that's all done within this neat code here because all we're doing is looping through. This is the only blade part. This is the templating part up here. This is the live wire part where we're connecting to something. And again, this is not a websocket connection. So, it's just sending HTML over the wire after a specific time frame when you have inputed in something into this text box where I'm like, hey, uh, let's do NIC.

  32. We send something over the wire. If I was to inspect this, that's what we would see. So, let's go ahead and do the network request right here. So, I'm going to say NIC. And we see over here we have this 200 fetch request.

  33. And we get a response back. And in that response we have a snapshot with some HTML that has the actual HTML that we are wanting back. So again it's not websocket connection but all of that code is neatly contained in this singular page where this PHP code this Laravel code uh doesn't change if we wanted to do this other than this being a component that exists within LiveWire.

  34. This piece of like searching doesn't really change. If I wanted to do this within an API, I would probably actually have to add some additional code if this was in a separate controller. But LiveWire gives you the primitives, not just to be able to say, hey, this is a new templating language. You have to learn this. You have to learn X, Y, or Z.

  35. It's more of like, hey, we're abstracting JavaScript so that when you write forms, when you display tables, when you need charts or image uploads or things like lazy loading, doing all that by hand within JavaScript and then using server rendered elements within the page, it it's possible. It can be done, but why would you want to do that when you already have uh ways to do it within LiveWire? because it's already been accomplished for you. It's already been done for you. It's already been solved.

  36. And yes, this has already also been solved within the front end. And that's why even Theo mention talking about inertia where you have this glue holding your backend and your front end together where livewire becomes both that glue and the addition or h enhancement on top of the templating language. So livewire is not just new syntax. It is an enhancement to existing syntax that exists within the framework that LiveWire was built for.

  37. It's a lot easier as a developer, especially if you're curious about Laravel, to know if you want to even think about writing Livewire when you know what LiveWire is not. Livewire is not websocket connections by default. So if you did need websocket connections by default, you can still use that with the tools and the primitives that Laravel Livewire gives, but that's not how it works out of the box. It is not the ability to replace the JavaScript. You still have to write JavaScript.

  38. In fact, it's encouraged to write JavaScript because you don't want everything to happen on the server. For me, this is the main selling point of why I started using LiveWire because I liked the idea of knowing, hey, I could just automatically send a form directly to the server all in one file. But I also know, okay, that me uh, you know, doing a toggle switch or a accordion that opens up showing something new that probably doesn't need to happen on the server.

  39. And so it's an easy way for my brain to think this is happens on the server, this happens on the client. And then last thing, it is not new syntax in the sense that it's not meant to be a new templating language. It is meant to enhance a templating language that is serverdriven by Laravel. So it is meant to enhance what is already exists within there while abstracting all things that you need to do within most applications.

  40. Things like forms, tables, file uploads, and so much more. If LiveWire intrigues you, I actually have a hour and a half video of a LiveWire crash course talking about a lot of these concepts in even more depth, but then also how would you apply this for most use cases. And so, it's a very basic level overview of how you might use LiveWire or how might how you might start using LiveWire, but that might be a great next step. And until next time, keep creating.

just you here