Kritim Yantra
Jan 08, 2026
“Laravel works… Vue works… but how do I connect them properly without breaking everything?”
Most beginners try mixing Blade, Vue, random scripts, and outdated tutorials. The result?
White screens, console errors, and a lot of frustration.
I’ve been there. So in this guide, we’ll do this the clean, modern Laravel 12 way, step by step, and build a working CRUD app you can actually understand.
No magic. No skipped steps.
We’ll create a simple Posts CRUD:
Laravel = the kitchen
Vue = the waiter
API = the order slip between them
Make sure you have:
Run:
composer create-project laravel/laravel laravel-vue-crud
cd laravel-vue-crud
Start the server:
php artisan serve
Laravel 12 uses Vite by default, which makes Vue setup much easier.
Install Vue 3 and related packages:
npm install vue@3 axios
Install Vue plugin for Vite:
npm install -D @vitejs/plugin-vue
vite.config.jsimport { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
vue(),
],
});
resources/js/app.jsimport { createApp } from 'vue';
import App from './App.vue';
createApp(App).mount('#app');
resources/js/App.vue
<template>
<div>
<h1>Laravel 12 + Vue 3 CRUD</h1>
<PostComponent />
</div>
</template>
<script setup>
import PostComponent from './components/PostComponent.vue'
</script>
resources/views/app.blade.php
<!DOCTYPE html>
<html>
<head>
@vite('resources/js/app.js')
</head>
<body>
<div id="app"></div>
</body>
</html>
routes/web.php
Route::get('/', function () {
return view('app');
});
php artisan make:model Post -m
Migration:
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('body');
$table->timestamps();
});
Run migration:
php artisan migrate
php artisan make:controller Api/PostController
app/Http/Controllers/Api/PostController.phpclass PostController extends Controller
{
public function index()
{
return Post::latest()->get();
}
public function store(Request $request)
{
return Post::create($request->validate([
'title' => 'required',
'body' => 'required',
]));
}
public function update(Request $request, Post $post)
{
$post->update($request->validate([
'title' => 'required',
'body' => 'required',
]));
return $post;
}
public function destroy(Post $post)
{
$post->delete();
return response()->noContent();
}
}
routes/api.php
use App\Http\Controllers\Api\PostController;
Route::apiResource('posts', PostController::class);
Now Laravel is officially your API backend.
resources/js/components/PostComponent.vue
<template>
<div>
<input v-model="form.title" placeholder="Title" />
<textarea v-model="form.body" placeholder="Body"></textarea>
<button @click="savePost">
{{ editing ? 'Update' : 'Create' }}
</button>
<hr>
<ul>
<li v-for="post in posts" :key="post.id">
<strong>{{ post.title }}</strong>
<button @click="editPost(post)">Edit</button>
<button @click="deletePost(post.id)">Delete</button>
</li>
</ul>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import axios from 'axios'
const posts = ref([])
const editing = ref(false)
const currentId = ref(null)
const form = ref({
title: '',
body: '',
})
const loadPosts = async () => {
posts.value = (await axios.get('/api/posts')).data
}
const savePost = async () => {
if (editing.value) {
await axios.put(`/api/posts/${currentId.value}`, form.value)
} else {
await axios.post('/api/posts', form.value)
}
form.value = { title: '', body: '' }
editing.value = false
loadPosts()
}
const editPost = (post) => {
form.value = { title: post.title, body: post.body }
editing.value = true
currentId.value = post.id
}
const deletePost = async (id) => {
await axios.delete(`/api/posts/${id}`)
loadPosts()
}
onMounted(loadPosts)
</script>
npm install
npm run dev
php artisan serve
Open:
http://localhost:8000
You now have a full Laravel 12 + Vue 3 CRUD app 🎉
npm run devapi.php)If your Vue UI breaks:
npm run devMost issues come from Vite not running.
Once you understand this flow, you can build dashboards, admin panels, and SPAs confidently.
If you want Vue without APIs, yes.
If you want clear frontend/backend separation, APIs are better.
Yes. Just run npm run build on the server and deploy Laravel normally.
Absolutely. Laravel Sanctum works great with Vue APIs.
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google
Kritim Yantra
Kritim Yantra