Kritim Yantra
May 01, 2025
Laravel 12, released in early 2025, brings a host of developer-focused improvements. One of the biggest highlights is its modernized frontend tooling powered by Vite and official starter kits that support Vue 3, React, and Livewire out of the box.
In this guide, we'll explore:
@vitejs/plugin-vue
Letβs dive in!
Laravel 12 continues Laravel's tradition of clean syntax and developer-friendly tooling. Some key enhancements:
Laravel 12 includes an official Vue Starter Kit that sets up everything you need: Vue 3 + Inertia.js + Tailwind CSS + Shadcn Vue components.
laravel new my-vue-app
cd my-vue-app
The Laravel installer will ask you to choose a frontend stack. Select:
> Vue starter kits
npm install
npm run dev
php artisan serve
Your Laravel app now includes a fully working Vue + Inertia setup. You can start creating pages in resources/js/Pages
.
@vitejs/plugin-vue
If you're building a custom stack or want Vue without Inertia, hereβs how to do it manually:
npm install vue
npm install --save-dev @vitejs/plugin-vue
vite.config.js
)import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
vue(),
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
],
});
resources/js/app.js
import './bootstrap';
import { createApp } from 'vue';
import Home from './components/Home.vue';
const app = createApp({});
app.component('home-component', Home);
app.mount('#app');
Create resources/js/components/Home.vue
:
<template>
<div>
<h2 class="text-2xl font-bold text-blue-600">Hello from Vue 3 in Laravel 12 π</h2>
</div>
</template>
<script setup>
// You can add logic here
</script>
<style scoped>
h2 {
margin: 10px 0;
}
</style>
Now that Vue is set up, you can render Vue components inside your Blade templates.
resources/views/welcome.blade.php
<!DOCTYPE html>
<html>
<head>
<title>Laravel 12 + Vue 3</title>
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body>
<div id="app">
<home-component></home-component>
</div>
</body>
</html>
The <div id="app">
is where Vue mounts, and home-component
is your Vue component.
Make sure this file is loaded through a web route:
// routes/web.php
Route::get('/', function () {
return view('welcome');
});
Now run the dev server and Laravel:
npm run dev
php artisan serve
π Youβll see your Vue component rendered inside the Blade file!
<script setup>
in Vue 3 components for simpler syntaxresources/js/components/
composables
, layouts
, pages
)#app
div to enable mountingnpm run build
before deploying to productionLaravel 12 is a game-changer for modern web development. With official Vue starter kits or a custom Vite-based setup, integrating Vue has never been easier or more flexible.
Whether you're building a single-page app or sprinkling interactivity into Blade files, Laravel 12 + Vue 3 is a perfect combo.
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google