Have you ever wanted to build dynamic, modern apps with Vue, React, or Svelte but still keep the power and simplicity of Laravel?
With Inertia.js, you can do exactly that!
What is Inertia?
Inertia is a tool that connects your Laravel backend with a frontend like Vue, React, or Svelte. It lets you build Single Page Applications (SPA) without creating a separate API.
Why use Laravel + Inertia?
No API needed: send data directly from your controller to your fronted.
Use Laravel Routes: no need to change your routing system.
Good For SEO(With SSR): server-side rendering is possible.
Modern UX: fast page loads without full reloads.
Simple Example
In your controller:
use Inertia\Inertia;
public function index()
{
return Inertia::render('Dashboard', [
'user' => Auth::user(),
]);
}
Vue component (Dash.vue)
<script setup>
defineProps({ user: Object })
</script>
<template>
<h1>Welcome, {{ user.name }}</h1>
</template>
That's it! No JSON APIs or duplicate routes.
Things to keep in mind
Inertia is not a frontend framework. You still need Vue or React setup.
Use
remember()
to keep state when navigating.Learn to use
preserveState
andpreserveScroll
for smoother updates.Good backend practices (like Form Requests) are still important.
When is Inertia a good choice ?
Use it when:
- You want SPA experience
- You like Laravel developer experience
- You don't want to build a full API.
Avoid it if:
- You need a fully separate fronted.
- You are building a mobile app that depends on an API.
Top comments (0)