Skip to content
Tutorials Center
My learning

Topics

Lesson 49 of 67 ยท Livewire and the Frontend

Blade, Livewire, Inertia or an SPA?

Compare the four ways to build a Laravel frontend - Blade, Livewire, Inertia and a separate SPA - see what each sends over the wire and learn how to choose.

Laravel does not force a frontend on you. You can render plain HTML with Blade, add server-driven interactivity with Livewire, ship a React or Vue interface through Inertia, or build a completely separate single-page application (SPA) that talks to a JSON API. Each choice changes where your code lives, what travels over the network and what skills your team needs.

This lesson helps you pick. You will see what each approach actually sends to the browser, run a small plain-PHP model of the four payload shapes, and finish with a decision guide. The Laravel code here is read-only; the runnable examples are stand-ins that show the shapes, not the real packages.

The four options at a glance

All four start the same way: a request reaches a Laravel route. They differ in what the response contains and who is responsible for the next interaction.

flowchart LR
    B["Browser"] --> R["Laravel route"]
    R --> A["Blade: full HTML page"]
    R --> L["Livewire: HTML + component state"]
    R --> I["Inertia: HTML shell + page object"]
    R --> S["SPA backend: JSON only"]

One route, four kinds of response. The choice is about what the server returns and who renders it.

  • Blade renders HTML on the server. Every navigation is a normal page load. Interactivity comes from small bits of JavaScript, often Alpine.
  • Livewire also renders on the server, but components stay on the page. When the user clicks or types, a small request goes to the server, which re-renders the component and sends back updated HTML. See Livewire Basics.
  • Inertia lets you write pages in React, Vue or Svelte while Laravel keeps routing, controllers and validation. A controller returns a page name plus props, and the client renders them.
  • A separate SPA is a JavaScript application that lives apart from Laravel (maybe on another domain) and calls a JSON API. Laravel is only the backend; see Building JSON APIs with API Resources.

Blade: the simplest thing that works

Blade pages are fast to build, work without JavaScript and are easy for search engines to read. A controller passes data, the template prints it:

PHP
Route::get('/posts', function () {
    return view('posts.index', [
        'posts' => Post::latest()->paginate(10),
    ]);
});

Choose Blade when your site is mostly content: marketing pages, blogs, documentation, admin tables, or any app where a page reload per action feels fine. It has the fewest moving parts, the cheapest hosting needs and the smallest JavaScript download. This very tutorial site works that way: HTML is rendered on the server and cached, and only small islands of JavaScript add behavior.

The limit shows up when screens become highly interactive: live filtering, drag and drop, multi-step forms that must not lose state. You can still do it with Alpine and fetch(), but you write the glue yourself.

Livewire: interactivity without leaving PHP

Livewire components are PHP classes (or single-file components in Livewire 4) with public properties and methods. The template binds to them:

PHP
<input type="text" wire:model.live="search">

@foreach ($this->posts as $post)
    <p>{{ $post->title }}</p>
@endforeach

When the user types, Livewire sends the new property value to the server, runs your PHP, and patches the DOM with the new HTML. You write no JavaScript for the common cases, you reuse validation, policies and Eloquent directly, and one developer can own the whole feature.

The trade-offs are real. Every interaction is a network round trip, so latency matters. State lives on the server and in the page, so you must think about what the browser can tamper with (public properties are user input, treat them that way). And highly animated or offline-first interfaces fit poorly.

Pick Livewire for dashboards, CRUD-heavy apps, forms with live validation and any team that is stronger in PHP than in JavaScript.

Inertia: a modern frontend with a classic backend

Inertia removes the API layer. A controller returns a page component name and its props:

PHP
use Inertia\Inertia;

Route::get('/posts', function () {
    return Inertia::render('Posts/Index', [
        'posts' => Post::latest()->paginate(10),
    ]);
});

On the first visit the server sends a full HTML shell with the page object embedded. When the user clicks an Inertia link, the browser makes an XHR request and receives a small JSON page object instead of a full page. The client-side framework swaps the component and props without a full reload. Routing, auth, validation errors and flash messages stay in Laravel, so you skip building and documenting a separate API.

Choose Inertia when you want React, Vue or Svelte components (a rich component ecosystem, client-side transitions) but a single codebase and deployment. The cost is a JavaScript build step, server-side rendering as an extra process if you need it for SEO, and a hard dependency between your controllers and your page components.

A separate SPA with a JSON API

In this model the frontend is its own project. Laravel exposes endpoints, usually protected with Sanctum, and the SPA fetches data and renders everything in the browser.

This is the right call when you must serve several clients from one backend (web app, iOS, Android, partners), when a dedicated frontend team deploys on its own schedule, or when the frontend must run offline. The cost is the highest: two codebases, API versioning, CORS, token or cookie authentication, duplicated validation messages and more testing surface.

The common mistake is choosing an SPA because it feels more professional. If you only have a web app and one team, you are paying for an API that nobody else uses.

Comparing what travels over the wire

Here is a runnable model of the same "list posts" screen in four shapes. These are simplified stand-ins, not real Laravel, Livewire or Inertia output, but the structure of each payload matches the idea described above.

PHP Four payload shapes for one screen

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

Look at what each one contains. Blade sends finished markup and nothing else. Livewire sends markup plus a snapshot so the next request can continue from the same state. Inertia and the API send only data, and the client turns it into HTML, which is why the client needs a rendering framework. The byte counts are tiny here; with real pages the difference to watch is not size but where rendering work happens: server for the first two, browser for the last two.

Choosing: a decision guide

Match the project to the first row that fits, then check the trade-offs.

PHP A small decision helper

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

This is a joke-sized model, but the order of questions is the useful part: ask about other clients first, because that decision forces an API. Then ask about your team's strengths, then about interactivity.

The official starter kits give you a working choice on day one: React, Vue and Livewire kits are built for Laravel 13, each with login, registration and a dashboard. Picking a kit is not a lifelong commitment, but moving from Livewire to Inertia later means rewriting every page, so decide before you have a hundred of them.

You can also mix approaches. A Blade marketing site with a Livewire dashboard behind login is common, and so is an Inertia app with one public API for a mobile client. Mixing works best when each area uses one approach consistently.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which approach re-renders a component on the server after each interaction and sends back updated HTML?

    Livewire keeps components on the page, sends property changes to the server and patches the DOM with the HTML it gets back. Inertia and SPAs render in the browser from data.
  2. 2. What does an Inertia controller return instead of a Blade view?

    Inertia::render() takes a client-side page component name and its props. The client framework renders them, so you need no separate API layer.
  3. 3. Your product needs a website, an iOS app and an Android app that all share one backend. What is the strongest reason this points to a JSON API?

    Native apps cannot use server-rendered HTML pages, so a documented API is the shared contract for every client.
  4. 4. Which is a genuine cost of choosing Livewire?

    Livewire's strengths come with latency per interaction and the need to treat browser-controlled state as untrusted. Eloquent and validation work fine inside components.

Summary

  • Blade, Livewire, Inertia and an SPA differ in what the server returns and where rendering happens.
  • Blade suits content and simple apps; it has the fewest moving parts.
  • Livewire gives interactivity in PHP with a round trip per action.
  • Inertia brings React, Vue or Svelte without building a separate API.
  • A JSON API with an SPA is justified mainly when several clients or teams share a backend.
  • Decide early, because switching later means rewriting every page.

Next: Testing with Pest