Kritim Yantra
May 14, 2025
Want to build modern, responsive, and interactive web apps using Laravel 12, Bootstrap, and Vue.js? You’re in the right place!
This tutorial is designed for absolute beginners, and by the end of this post, you’ll be able to build a simple task manager using Laravel on the backend, Bootstrap for styling, and Vue.js for front-end interactivity.
✅ How to install and set up Laravel 12
✅ How to integrate Bootstrap 5 for beautiful UI
✅ How to use Vue 3 with Laravel and Vite
✅ How to build a simple CRUD Task Manager App
Let’s get started!
Make sure you have the following installed:
composer global require laravel/installer
laravel new laravel-vue-bootstrap
cd laravel-vue-bootstrap
php artisan --version
You should see something like:
Laravel Framework 12.x.x
Bootstrap gives you a ready-made responsive design system.
npm install bootstrap@5 @popperjs/core
In resources/js/app.js
, add:
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap';
npm run dev
That’s it! Bootstrap is now ready to use in your Laravel views.
Laravel 12 works great with Vite and Vue 3.
npm install vue@3 @vitejs/plugin-vue
vite.config.js
:import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [
laravel({
input: ['resources/js/app.js'],
refresh: true,
}),
vue(),
],
});
app.js
:import { createApp } from 'vue';
import ExampleComponent from './components/ExampleComponent.vue';
const app = createApp({});
app.component('example-component', ExampleComponent);
app.mount('#app');
Create resources/js/components/ExampleComponent.vue
:
<template>
<div class="alert alert-info">
Hello from Vue!
</div>
</template>
<script>
export default {
name: 'ExampleComponent',
};
</script>
In resources/views/welcome.blade.php
:
<div id="app">
<example-component></example-component>
</div>
@vite('resources/js/app.js')
Let’s create a simple task manager where users can add and view tasks.
php artisan make:model Task -m
In the migration file (database/migrations/xxxx_create_tasks_table.php
):
$table->string('title');
$table->timestamps();
Run the migration:
php artisan migrate
Generate a controller:
php artisan make:controller TaskController
In routes/web.php
:
use App\Http\Controllers\TaskController;
Route::get('/', [TaskController::class, 'index']);
Route::post('/tasks', [TaskController::class, 'store']);
In app/Http/Controllers/TaskController.php
:
use App\Models\Task;
use Illuminate\Http\Request;
class TaskController extends Controller
{
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('/');
}
}
Create the Blade file: resources/views/tasks.blade.php
<!DOCTYPE html>
<html>
<head>
<title>Task Manager</title>
@vite('resources/js/app.js')
</head>
<body class="container py-5">
<h2 class="mb-4">Vue Task Manager</h2>
<div id="app">
<task-app :initial-tasks='@json($tasks)'></task-app>
</div>
</body>
</html>
Create resources/js/components/TaskApp.vue
:
<template>
<div>
<form @submit.prevent="addTask" class="mb-3">
<div class="input-group">
<input v-model="newTask" class="form-control" placeholder="Enter task">
<button class="btn btn-primary">Add</button>
</div>
</form>
<ul class="list-group">
<li v-for="task in tasks" :key="task.id" class="list-group-item">
{{ task.title }}
</li>
</ul>
</div>
</template>
<script>
export default {
props: ['initialTasks'],
data() {
return {
tasks: this.initialTasks,
newTask: '',
};
},
methods: {
addTask() {
fetch('/tasks', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify({ title: this.newTask })
})
.then(() => {
this.tasks.push({ title: this.newTask });
this.newTask = '';
});
}
}
};
</script>
Update app.js
to register the new component:
import { createApp } from 'vue';
import TaskApp from './components/TaskApp.vue';
createApp({
components: { TaskApp }
}).mount('#app');
Your Laravel app now:
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google