Kritim Yantra
May 14, 2025
Laravel 12 is here — powerful, clean, and ready for the future. If you're a beginner looking to combine Laravel's backend strength with React.js and Bootstrap 5, this tutorial is for you.
We’ll walk you through building a simple Task Manager App using these tools — no advanced experience needed.
Before starting, make sure you have:
✅ PHP 8.2 or higher
✅ Composer (PHP package manager)
✅ Node.js + npm installed
✅ A text editor like VS Code
✅ Basic terminal knowledge
Let’s start by creating a new Laravel project.
composer global require laravel/installer
laravel new laravel-react-bootstrap
cd laravel-react-bootstrap
You now have a fresh Laravel 12 setup! Check the version:
php artisan --version
You should see something like:
Laravel Framework 12.x.x
Bootstrap makes your app look clean and responsive.
npm install bootstrap@5 @popperjs/core
Open resources/js/app.js
and add:
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap';
npm run dev
You now have Bootstrap working with Laravel + Vite!
Now let’s add React to our Laravel project using Vite.
npm install react react-dom @vitejs/plugin-react
vite.config.js
:import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [
laravel({
input: ['resources/js/app.jsx'],
refresh: true,
}),
react(),
],
});
Create a new file: resources/js/app.jsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import TaskApp from './components/TaskApp';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<TaskApp />);
Let’s create a basic Task model and controller to manage tasks.
php artisan make:model Task -m
In the migration file, update like this:
$table->string('title');
$table->timestamps();
Run migration:
php artisan migrate
php artisan make:controller TaskController
In routes/web.php
, add:
use App\Http\Controllers\TaskController;
Route::get('/', [TaskController::class, 'index']);
Route::post('/tasks', [TaskController::class, 'store']);
Inside TaskController.php
:
use App\Models\Task;
use Illuminate\Http\Request;
public function index() {
$tasks = Task::all();
return view('tasks', compact('tasks'));
}
public function store(Request $request) {
$request->validate(['title' => 'required']);
Task::create($request->only('title'));
return redirect('/');
}
In resources/views/tasks.blade.php
:
<!DOCTYPE html>
<html>
<head>
<title>Task Manager</title>
@vite('resources/js/app.jsx')
</head>
<body class="container py-5">
<div id="root" data-tasks='@json($tasks)'></div>
</body>
</html>
Create a new file: resources/js/components/TaskApp.jsx
import { useState } from 'react';
import axios from 'axios';
export default function TaskApp() {
const initialTasks = JSON.parse(document.getElementById('root').dataset.tasks);
const [tasks, setTasks] = useState(initialTasks);
const [newTask, setNewTask] = useState('');
const addTask = async (e) => {
e.preventDefault();
await axios.post('/tasks', { title: newTask });
setNewTask('');
window.location.reload(); // quick reload for demo
};
return (
<div>
<form onSubmit={addTask} className="mb-3">
<div className="input-group">
<input
value={newTask}
onChange={e => setNewTask(e.target.value)}
className="form-control"
placeholder="New Task"
required
/>
<button className="btn btn-primary">Add</button>
</div>
</form>
<ul className="list-group">
{tasks.map(task => (
<li key={task.id} className="list-group-item">
{task.title}
</li>
))}
</ul>
</div>
);
}
You now have a beautiful, working Laravel 12 application using:
✔ Laravel for backend
✔ React.js for frontend interactivity
✔ Bootstrap for styling
Here’s what you can do to expand this project:
api.php
routesFor production builds, run:
npm run build
php artisan config:cache
This will optimize your Laravel + React app for deployment!
You’ve just built your first Laravel 12 + React + Bootstrap app — congratulations! 🎉
With this stack, you can create powerful, real-time applications using the best tools in modern web development. Keep learning, keep building.
Transform from beginner to Laravel expert with our personalized Coaching Class starting June 23, 2025. Limited enrollment ensures focused attention.
1-hour personalized coaching
Build portfolio applications
Industry-standard techniques
Interview prep & job guidance
Complete your application to secure your spot
Thank you for your interest in our Laravel mentorship program. We'll contact you within 24 hours with next steps.
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google