I have some experience with Laravel and Recently I have learned Vue js. Now At this stage, I am confused on What is the best way to use Laravel with Vue js. Some people recommend using Intersia js. Some have set up vue js inside Laravel and use it without inertia js. Some people advise to setup both projects separately like creating Laravel in a separate folder called Backend and Vue js in a separate folder called Front end then using that.
So I am confused a lot about what is the best way and which one is preferred in the industry. Thanks
Inertia and "separate projects" are difficult for beginners, so they should be avoided.
Hard disagree. Inertia makes it way easier to work with Vue. It's much easier than using API endpoints and separate routing.
@hamza1024 I recommend InertiaJS. The easiest way to get started is with a starter kit like Breeze. Here's how you install and run it in a fresh project:
composer require laravel/breeze --dev
php artisan breeze:install
php artisan migrate
npm install
npm run dev
You can check how the controllers return Inertia pages and pass data to the front-end. Then read the Inertia docs on how to use routes and forms on the front-end. Then you'll know 95% of what you need to know about Inertia.
I think the best way to use vue with laravel is to use it with Inertia JS. Given that you just learnt Vue, this is the best option. Advantages with Inertia:
Laravel handles the routing of the app. No need to configure separate router in Vue
Data passed as components to vue. No need for sepcial gimmicks to pass data from php to vue.
Comes with Server side rendering (SSR) making your app seo friendly and super fast.
Disadvantages with other methods you mentioned:
needs more work with configuring routers, may need api authentication with sanctum. Not sure if it can handle SSR
Give Inertia.js a try. You will love it.
Hope this helps.
@vishy@serialxtech.com Thanks @vishy@serialxtech.com for this brief Answer. Someone from the industry guided me to go with the Separate Folder Method like Creating a frontend folder and Creating a Backend Folder and Doing the work. This will help me to understand more and I think it's hard for beginners. By the way, I have 2+ years of experience with Laravel. Let's see I will give it a try to use inertia JS. In the end, the Client needs a working product. Mostly 90% never go inside the technical details of the product. They only want a working version. That's it. So I think First I will start with inertia JS and then go to these separate Folder techniques. What you do think about that?