Skip to content
Muhammet Şafak
tr

UI scale in Laravel: from Blade to SPA

Blade, Alpine.js, Livewire, Inertia.js, and SPA: choosing the UI tool in a Laravel project by interaction density, SEO needs, and the team.

Tan holding a blueprint

Laravel · UI

UI scale in Laravel: from Blade to SPA

Each step answers a different need. The choice is made not by tool quality but by interaction density, visibility requirements, and the team.

Muhammet Şafak

Date of the sources

This visual is based on posts from 2020-2021

  • DateThe source posts were written in 2020 and 2021. The visual has no version-specific detail; the decision logic was carried over.

The difference between Alpine and Vue

The difference is not tool quality, it is scale.

When “an SPA for everything” becomes the starting point, the trade-offs disappear from view. A project's visibility requirement is also part of the architectural decision.

The steps

Five scales from Blade to SPA

  1. Step 1: BladeThe familiar path: the template is rendered on the server.
  2. Step 2: Alpine.jsA few independent interactions in the template: dropdown, accordion, conditional form field.
  3. Step 3: LivewireA form-heavy panel; each interaction is one request to the server, and DOM diffs are applied.
  4. Step 4: Inertia.jsThe monolith stays, the UI is Vue or React; no API to write, a single client.
  5. Step 5: SPA + APIA separate codebase; mobile or third-party clients can consume the API too.

Decision map

Interaction density and search visibility

The vertical axis shows whether the page needs to be found by search engines; the horizontal axis shows how dense the client-side interaction is.

Content behind a login ↔ SEO required

  • Blade + Alpine.js

    Rendered on the server

    • HTML arrives complete from the server
    • Alpine is enough for a few independent interactions
  • SSR, SSG, or ISR

    Next.js, Nuxt.js

    • New content-heavy project: SSG or ISR
    • The bot sees the full content on first load
  • Livewire

    Admin panel

    • Filtering, pagination, form steps
    • A server round-trip is acceptable
  • Inertia.js or SPA

    Behind a login

    • If content is behind a login, SEO is not a real problem
    • One client: Inertia; multiple clients: a separate API

Little interaction ↔ Heavy interaction

Two projects, same year

Livewire and Inertia.js

Livewire and Inertia.js
TopicLivewireInertia.js
Who it is forA backend-focused team; minimal JavaScriptA team with a frontend developer on board
UIA PHP class and a Blade viewA Vue or React page component
Suitable projectA form-heavy admin panelComplex client-side interaction
LimitEvery interaction is an HTTP request; latency shows at high frequencyServer and client are tightly coupled; the frontend cannot evolve independently

How Inertia.js works

An SPA feel without an API

  1. Step 1: Click a linkInertia intercepts the page transition.
  2. Step 2: ControllerInertia::render() returns the page component and its data.
  3. Step 3: JSON responseThe component name and props arrive; shared data is added to every response.
  4. Step 4: Update in placeNo full page reload; the component updates in place.

Search visibility in an SPA

Four options

Four options
OptionHow it worksGain and cost
SSRHTML is generated on the server on every requestThe bot sees the full content on first load; it consumes server resources and needs a Node.js server
SSGAll pages are generated at build timeServed from a CDN, very fast; build time grows, limited for dynamic content
ISRGenerated statically, refreshed in the background at set intervalsBalances SSG's build time against SSR's server load
PrerenderPre-rendered HTML for bots, the SPA for usersLow conversion cost; an extra dependency, content may fall out of sync

The right match for the job

Using Alpine.js and Livewire at their own scale

Do

  • Keep Alpine for small, independent interactions in the template
  • Let Alpine open the modal instantly, and Livewire fetch the data in the background
  • On form fields, use wire:model.lazy so you don't fire a request on every keystroke
  • Move growing x-data logic into a separate component file

Don’t

  • Don't load cross-page state and complex component communication onto Alpine
  • Don't leave instant search, drag-and-drop, and animation to a server round-trip
  • Don't leak business logic into the template
  • Don't expect Livewire to handle complex client state
Tan thinking, hand on chin

Before you choose

Decision questions

  • Are the pages reached without logging in and found through search engines? (pending)
  • Is the interaction heavy, does the user expect millisecond precision? (pending)
  • Is there someone on the team who can write Vue or React? (pending)
  • Will a client other than the web UI consume the API? (pending)

SPA and authentication

Cookie or token?

  • TipFor an SPA on the same root domain (same-site), a cookie-based session is cleaner; the hassle of storing and refreshing tokens goes away.
  • WarninglocalStorage is open to XSS attacks; don't store the token there.
  • NoteThe SPA and the API can be on different subdomains, but not on different root domains. Beyond that limit, you move to the token model.
  • PitfallIf you use subdomains, the cookie domain must be set with a leading dot (.example.com); otherwise the cookie goes to only one subdomain.

Share and download

Search the site

Start typing to search posts, projects and pages.

Escto closePowered by Pagefind