
August 14, 2026
12 min read
By Kokil Thapa | Last reviewed: September 2026
You want Vue interactivity without turning Laravel into two disconnected codebases. This Vue with Laravel Setup Complete Guide walks through the current stack: Laravel 13, Vue 3, and Vite 8 on Node.js 26 LTS. The goal is a setup that builds cleanly, hot-reloads reliably, and deploys without Node on production. If you are weighing server-driven UI against client-side Vue, start with my Laravel Livewire tutorial for beginners — then return here when custom Vue components are the right call.
vue and @vitejs/plugin-vue, configure vite.config.js with the Laravel Vite plugin, mount Vue from resources/js/app.js, and load assets via @vite in Blade. Choose Inertia for monolithic apps or Sanctum for decoupled SPAs.How do you configure Vite for Vue with Laravel in 2026?
Laravel Mix is legacy territory. New projects ship with Vite 8.x and the official laravel-vite-plugin. Vite gives you fast Hot Module Replacement and hashed production assets. Misconfigured paths cause blank screens — the most common first-day failure.
Prerequisites and dependencies
Start from Laravel 13 on PHP 8.3 or higher. Laravel 12 on PHP 8.2 still works if you are mid-upgrade. Use Node.js 26 LTS and npm 12. Run Composer 2.10 for PHP packages.
composer create-project laravel/laravel my-vue-app
cd my-vue-app
npm install vue @vitejs/plugin-vue
npm install -D sass Install sass when components use <style lang="scss">. Without it, Vite fails on SCSS blocks with errors that look like Vue compiler bugs.
Production-ready vite.config.js
The config below matches what I use on production Laravel applications. It wires Laravel inputs, Vue SFC support, and a @ alias for clean imports.
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import path from 'path';
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './resources/js'),
},
},
}); The transformAssetUrls block matters. Vue may treat image paths as JS imports without it. Broken product images in production often trace back to this single setting. For deeper Vite tuning, see my Vite config guide for Laravel projects.
Bootstrapping Vue in app.js
Use Vue 3 with the Composition API. Mount from resources/js/app.js and reference the entry in your layout.
import { createApp } from 'vue';
import App from './App.vue';
createApp(App).mount('#app'); Your Blade layout needs a mount point and the Vite directive. Never use the old mix() helper on Laravel 12 or 13.
<!DOCTYPE html>
<html lang="en">
<head>
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body>
<div id="app"></div>
</body>
</html> Run npm run dev for local HMR. Run npm run build before deploy. The official Laravel Vite documentation covers environment-specific options if you need SSR or multiple entry points.
Should you use Inertia.js or a standalone SPA with Vue and Laravel?
This choice shapes every sprint after setup. Inertia keeps routing on Laravel. A standalone SPA moves routing to Vue Router and forces you to design a real API. On legal-tech portals I have built, dashboards often suit Inertia. Public APIs or mobile clients push you toward Sanctum.
| Criteria | Inertia.js + Vue | Standalone SPA + Sanctum |
|---|---|---|
| Routing | Laravel routes and controllers | Vue Router on the client |
| Data flow | Props from controller responses | JSON from /api/* endpoints |
| Authentication | Session cookies (automatic) | Sanctum SPA cookies or API tokens |
| SEO | Easier with server-rendered shell | Needs SSR, prerender, or hybrid pages |
| API reuse | Low — tied to web controllers | High — same API for web and mobile |
| Best fit | Internal tools, admin dashboards | Marketplaces, mobile-first products |
When Inertia.js wins
Inertia returns Vue page components from ordinary Laravel controllers. You skip API versioning, resource transformers, and token refresh logic. For web-only products, that cuts boilerplate sharply. Custom admin UI that Filament cannot cover is a common Inertia use case. Compare options in my Livewire 3 vs Inertia guide. For zero-custom-JS admin panels, see the Filament admin panel tutorial instead.
When a standalone SPA wins
Choose a decoupled SPA when mobile apps, third-party integrations, or headless consumers need the same backend. Sanctum handles cookie auth for your Vue app and token auth for mobile. You own loading states, error handling, and route guards in Vue. Read Laravel API best practices before you commit — bad endpoints are expensive to fix later. For auth specifics, see Sanctum vs Passport and building a REST API with Sanctum.
How do you mount Vue components inside existing Blade pages?
Not every project needs a full SPA on day one. Laravel supports islands of Vue inside server-rendered pages. This pattern works well for booking widgets, search filters, and document upload UIs.
Multiple entry points
Add extra inputs in vite.config.js for each mount point. A dashboard page and a public catalog can share one build but load different bundles.
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js',
'resources/js/booking-widget.js',
],
refresh: true,
}), In Blade, call @vite(['resources/js/booking-widget.js']) only on pages that need it. Smaller JS payloads help Core Web Vitals on content-heavy sites.
Alpine.js as a lighter alternative
For toggles, dropdowns, and small forms, Alpine.js inside Blade may be enough. It avoids a build step for simple interactivity. Read Alpine.js for interactive Blade templates before defaulting to Vue everywhere. Vue earns its place when state, validation, or component reuse grows beyond a few lines.
How do you set up state management and API calls in Vue?
Small apps can rely on props and composables. Larger SPAs need Pinia for shared state. Vuex 4 still works but Pinia is the default for new Vue 3 projects.
For standalone SPAs, configure axios or fetch with Sanctum credentials. Call /sanctum/csrf-cookie before POST, PUT, or DELETE requests. Inertia skips this step because Laravel handles CSRF on full page requests.
import axios from 'axios';
axios.defaults.withCredentials = true;
axios.defaults.withXSRFToken = true;
await axios.get('/sanctum/csrf-cookie');
await axios.post('/api/bookings', { date: '2026-09-15' }); Pinia stores keep user session and cart data out of prop-drilling hell. See Pinia vs Vuex 4 for migration notes. For component structure, my Vue 3 Composition API deep dive covers patterns that scale on real client projects.
What are common Vue with Laravel setup mistakes in 2026?
These issues show up on support forums and in production logs. Most trace back to environment mismatch or legacy Mix habits.
- HMR stuck on localhost: Remote dev over SSH or Docker needs explicit HMR host config in Vite. Add
server: { hmr: { host: 'your-app.test' } }or the browser never receives updates. - 419 CSRF on SPA POST: Standalone Vue apps must call
/sanctum/csrf-cookiefirst. Inertia handles CSRF through normal form semantics. - Wrong env prefix: Vite exposes only
VITE_*variables. LegacyMIX_*names from Mix projects return undefined in Vue code. - Production build on the server: Running
npm run buildon a VPS invites version drift. Build in CI and shippublic/build/as an artifact. - Cached prod assets during dev: Stale files in
public/build/make DevTools report no Vue instance. Delete the folder and restart Vite. - TypeScript gaps: Add
"types": ["vite/client"]totsconfig.jsonsoimport.meta.envresolves in the IDE.
Environment variables and security
Never prefix secrets with VITE_. Those values ship to every browser. Keep API keys, database credentials, and payment secrets in PHP-only .env entries. Public values like VITE_APP_NAME and VITE_API_URL are fine. When debugging API payloads locally, a JSON formatter saves time parsing responses.
Migrating from Laravel Mix
Older Laravel 10 and 11 projects may still use Mix. Replace mix() with @vite one layout at a time. Compare bundlers in Vite vs Webpack for frontend builds. Finish migration before jumping to Laravel 13 — Mix no longer receives first-party support.
How do you deploy Vue with Laravel applications to production?
Production servers should run PHP, not Node. I deploy sister legal-tech sites with Deployer 7 and GitLab CI on shared EC2. Assets build in CI, then PHP-FPM serves hashed files from public/build/.
Artifact-based deployment steps
- Build in CI: Use Node.js 26 LTS. Run
npm ci, notnpm install, for reproducible lockfile installs. - Verify manifest: Confirm
public/build/manifest.jsonexists with hashed filenames before deploy. - Ship artifacts: Upload
public/build/or commit it if your team accepts that trade-off on small projects. - Zero-downtime swap: Deployer symlinks the new release. Reload PHP-FPM to clear opcache.
- Smoke test assets: Load one page and confirm JS and CSS return 200, not 404.
Full pipeline details live in my zero-downtime Deployer guide. On booking systems like Adventure Third Pole Trek, Laravel plus Livewire handles most UI — but the same deploy pattern applies when Vue bundles ship alongside Blade.
CDN and cache headers
Vite hashes filenames in production. Serve JS and CSS with long cache lifetimes. Keep HTML uncached so browsers pick up new manifest entries. Purge CDN cache on manifest changes only — not every asset file. That pattern cuts bandwidth for Nepal users on slower connections.
How does Vue with Laravel compare to other 2026 frontend options?
Vue is not always the answer. Pick based on team skills, SEO needs, and whether you need a public API.
- Livewire: No separate frontend build. Best for CRUD dashboards when Vue hiring is hard. See the Livewire tutorial for a full walkthrough.
- Filament: Admin panels without writing Vue. Ideal when standard CRUD covers 90% of back-office work.
- React + Inertia: Larger global talent pool. Steeper curve for PHP-first teams.
- HTMX: Minimal JS for progressive enhancement. Poor fit for persistent client state.
Vue hits a sweet spot for PHP developers learning modern frontend. The Vue 3 documentation is clear, and Laravel packages for Inertia and Sanctum are mature. For agency work spanning law portals and e-commerce, Vue skills transfer across project types. Review modern Laravel architecture best practices so your backend structure supports whichever frontend you pick.
Need a team to implement this stack? Our web development services in Nepal cover Laravel, Vue, deployment, and ongoing maintenance. You can also reach out directly via contact me for architecture review.
Key Takeaways
- Install Vue 3 with
@vitejs/plugin-vueon Laravel 13, Node.js 26 LTS, and Vite 8 — not Mix. - Choose Inertia for web-only monoliths; choose Sanctum SPA when mobile or third parties need the same API.
- Call
/sanctum/csrf-cookiebefore mutating requests in standalone SPAs to prevent 419 errors. - Build assets in CI and deploy
public/build/artifacts — never run npm on production servers. - Use
VITE_*env vars only for public values; keep secrets in PHP-side.enventries. - Start with Vue islands in Blade for small widgets; graduate to full SPA only when state complexity demands it.
People Also Ask
Does Laravel 13 include Vue by default?
No. Laravel ships with Vite and a minimal JavaScript entry point. You install Vue manually with npm install vue @vitejs/plugin-vue and configure the plugin in vite.config.js. Jetstream with Inertia is an optional starter kit if you want scaffolding.
Can you use Vue with Laravel without Inertia?
Yes. Mount Vue on a Blade page with a single #app div, or build a full SPA with Vue Router and Sanctum. Inertia is optional — it just removes the need to build a separate JSON API for web-only apps.
Is Vite required for Vue in Laravel?
For current Laravel versions, yes. Mix is deprecated for new work. Vite is the official bundler and powers HMR during development plus hashed assets in production.
How do you fix Vue HMR not updating in Laravel?
Check that npm run dev is running and @vite points to the correct entry files. For remote or Docker dev, set an explicit HMR host in vite.config.js. Clear stale files in public/build/ if production assets shadow dev mode.
Ship your Vue with Laravel Setup Complete Guide stack
A clean Vue with Laravel Setup Complete Guide setup saves months of debugging later. Configure Vite 8 correctly, pick Inertia or Sanctum deliberately, and deploy assets from CI from day one. Skip tutorials that still reference Mix, Vue 2, or Node 18 — they will waste your afternoon. If you want hands-on help scoping architecture or implementing the full stack, contact us for a review tailored to your project.
Frequently Asked Questions
0 Comments
Leave a comment
Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

