Kritim Yantra
Jan 08, 2026
So let’s cut through the noise and walk through the best current way to set up Laravel 12 with React step by step, using the official recommended tooling like Vite, Inertia, and Laravel’s React starter kit. This gives you a real, modern app setup: Laravel routes + controllers powering a React UI in one project.(Laravel)
You will set up a project where:
This approach feels like building a single app, not two separate apps glued together.(Laravel)
Earlier ways of integrating React with Laravel involved:
Those still work, but Laravel 12 comes with a first-class integration using Vite + Inertia + official starter kits that make building SPAs much easier.(Laravel)
First, make sure you have:
Run:
composer create-project laravel/laravel my-app
Navigate in:
cd my-app
Laravel 12 now includes starter options that scaffold React + Inertia for you:
laravel new my-app
# When asked, pick: React
This installs:
Then install dependencies:
npm install
composer install
And start dev builds:
npm run dev
Now run Laravel:
php artisan serve
Visit:
http://localhost:8000
You now have a React frontend integrated with Laravel.(Laravel)
In this setup:
📁 resources/js
👉 React components, pages, layouts live here
📁 resources/js/pages
👉 These map to Inertia pages
📁 resources/js/app.jsx
👉 Vite entry — bootstraps React and connects to Laravel
📁 routes/web.php
👉 Laravel routes render React pages via Inertia.
Controller example:
use Inertia\Inertia;
Route::get('/', function () {
return Inertia::render('Welcome', [
'appName' => config('app.name'),
]);
});
React page example:
export default function Welcome({ appName }) {
return <h1>Welcome to {appName}</h1>;
}
Inertia sends Laravel data as React props.(Laravel)
Think of Inertia as a bridge:
Laravel = Backend Server
React = Frontend UI
Traditionally you’d build two separate apps and connect them with APIs.
With Inertia:
So your app feels like a single cohesive stack — no separate React server to manage.(Laravel)
Create a React page:
resources/js/pages/About.jsx
export default function About() {
return <h1>This is the About Page</h1>;
}
Laravel route:
Route::get('/about', function () {
return Inertia::render('About');
});
Now visiting /about shows your React page — with full SPA behavior!(Laravel)
Thanks to Vite, your React components auto-refresh while you code:
npm run dev
Vite keeps browser reloads fast — ideal for modern frontend dev.
If you prefer:
You can still do that. Just:
routes/api.phpfetch or axiosThat’s a good choice for teams where frontend and backend are decoupled, but it’s not the focus of the Laravel 12 starter kit.(Laravel Daily)
You don’t juggle two repos — backend + frontend live together.(Laravel)
Controllers pass props → React consumes them.(Laravel)
Instant reloads without waiting for compilation.(Laravel)
Laravel starter kit even gives login/register, Tailwind UI, and layouts ready to go.(Laravel)
✔ Always commit your vite.config.js — it determines how React is compiled.(Medium)
✔ If React pages fail to load, check the Vite dev server console.
✔ Use Inertia shared props for common data like authenticated user.
✔ Use /api/* routes for pure JSON endpoints if needed.
✅ Use Laravel’s React starter kit for the smoothest experience.
✅ Inertia binds Laravel and React in one full-stack project.
✅ Vite handles fast builds with React plugins.
✅ You don’t need separate frontend projects unless you want to.
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google
Kritim Yantra