Shibu0708's avatar

VueJs as separate Installation or use VueJs within Laravel

What we need to know, is whether to keep Vue JS as separate Installation or Use Within Laravel Installation.

1 like
5 replies
LaryAI's avatar
Level 58

Certainly! Here’s a clear and structured answer for the given Laracasts forum question:


When deciding between using Vue.js as a separate installation or within a Laravel installation, you should consider your project’s requirements, team structure, and future scaling. Here’s an explanation of both approaches and guidance on how to choose:

1. Use Vue.js Within Laravel (Monolithic / SPA via Laravel Mix/Vite)

This is the approach where you include Vue.js in your Laravel project using Laravel Mix (Webpack) or Vite (in newer Laravel versions). Your backend and frontend remain in a single codebase.

Pros:

  • Easier to get started for small to medium-sized projects.
  • Both backend (Laravel) and frontend (Vue.js) are in one repo.
  • Simple deployment process.
  • Tight coupling simplifies working with Laravel features (middleware, auth, etc.).
  • Out-of-the-box support for SSR solutions like Inertia.js.

Best For:

  • Projects where the frontend and backend will be maintained by the same developers or team.
  • Internal admin panels, dashboards, and smaller applications.

How:

composer require laravel/ui
php artisan ui vue
npm install
npm run dev

Or, with Laravel Breeze/Jetstream/Inertia.js, which supports Vue.js seamlessly.


2. Use Vue.js as a Separate Installation (Decoupled / API-driven)

Here, Vue.js is set up as its own project (usually with the Vue CLI or Vite) and communicates with Laravel via API calls (typically REST or GraphQL).

Pros:

  • Frontend and backend can be developed, deployed, and scaled independently.
  • Teams can work on frontend and backend simultaneously.
  • Best for microservices and large scale applications.
  • Easier to switch out or update tech stacks in the future.

Best For:

  • Public-facing apps with rich interactivity.
  • Projects that might need to support multiple frontends (web, mobile, etc.).
  • Larger teams where front-end and back-end roles are separate.

How:

  1. Create a new Vue project:
npm create vite@latest my-vue-app -- --template vue
cd my-vue-app
npm install
npm run dev
  1. Set up Laravel as an API-only backend (consider using laravel new my-api && composer require fruitcake/laravel-cors).
  2. Use Axios or another HTTP client in your Vue app to consume Laravel’s API.

Summary Table

Approach Recommended For Example Stack
Within Laravel Small/medium apps, dashboards Laravel + Vue (Mix/Vite)
Separate Install Large/public apps, split teams/stacks Laravel API + Vue CLI/Vite

In conclusion:

  • For smaller projects or when starting, use Vue within Laravel.
  • For scalable, complex projects or when teams are distinct/separate, go for a decoupled setup.

If your application may need to grow in complexity in the future, starting with a separate installation could save you future migration headaches.


Let me know if you want an implementation example of either approach!

1 like
Shibu0708's avatar

Thanks for the reply,

How to handle this, if there is any Laravel upgrades happen (i.e.) version upgrade from Laravel 12 to Laravel 13 for both the cases above (Vue JS within and outside)

1 like
vincent15000's avatar
Level 63

Without any doubt, you can use VueJS within Laravel if you need to develop an entire application with a backend and a frontend. Furthermore you can use InertiaJS to get it easier to integrate VueJS inside Laravel.

Your question is interesting only if you need for example to develop a backend used with a mobile application, where you have a real separation between the backend and the frontend.

But even in this case, you can now develop the frontend of a mobile application with Laravel and VueJS using NativePHP.

imranbru's avatar

A Laravel upgrade has absolutely zero impact on your Vue frontend. Since they only communicate via an API, you just run through the Laravel upgrade guide for the backend. As long as your API endpoints and JSON responses don't change their shape, your Vue app won't even know the backend was upgraded. It provides total isolation.

Upgrading is still mostly isolated, but they share the same repository. When upgrading to Laravel 13, you'll update your composer.json and fix any PHP-side breaking changes. Occasionally, a major Laravel release might include updates to default scaffolding, meaning you might need to bump an NPM package (like @inertiajs/vue3 or laravel-vite-plugin), but your actual .vue components and frontend logic almost never need to be touched.

2 likes

Please or to participate in this conversation.