Is it best practice to use Vue component in blade template? - laravel

I'm using multiple Vue components in Laravel blade template like below
<div id="app">
<user-list></user-list>
<first-component></first-component>
<seconde-component>
<h1>{{ $name }}</h1>
<p>{{ $bio }}</p>
</seconde-component>
</div>
I want to know if it's best practice to use Vue like this or not? If
not, what is best practice for using Vue components in Laravel?

Laravel has VueJS support right out of the box. You can you use any front-end library like AngularJS or ReactJS too inside if you Laravel app. According to the Laravel docs there is not a "best practice or method" to using VueJS in Laravel. It it just supported if you choose to use the library.
To help your Laravel application you can setup a VueJS router for live loading, use ajax to get json from your laravel app without refreshing, est.

Related

Few questions when it comes to building an e-commerce website in Laravel and vue

I have a few questions regarding building an e-commerce website. I want to program a small e-commerce website using Laravel and Vue. I know the basics of Laravel and Vue, but I'm struggling when it comes to selecting the best plan to program the website. So I have a few questions regarding that.
Should an e-commerce website be dynamic or SPA?
Should I use a Vue router or built-in Laravel router?
Is it good practice to mix Vue components and Blade Template or should I separate Vue and Laravel when it comes to the frontend?
Suggest you use nuxt universal, cuz need seo, spa didnt index well in search engine
For client side use Vue router, for rest api use laravel router
If you use vue + nuxt dont need blade

How to Use Vuejs on Laravel blade

everyone, I want to make a dormitory management system with laravel and vuejs but I don't know how to display my data instead of "welcome.blade.php" file but instead of "blade" use vue component if someone knows this please help me how to do this. I use API route for this
thanks everyone
You don't use it instead of blade you mostly use it with or inside blade.
Use Vue like normally would just treat your blade template as your plain HTML.

Laravel API and Vue SPA or inline Vue?

When working with Laravel, it seems I can use Vue inside the Laravel Blade but I can also use Laravel project only as an API while using another project (Vue in this case) as a front-end connecting to the API?
Which approach is better and has its advantages/disadvantages?

Laravel: Using a mix between Blade and Vuejs

I'm developing a website using Laravel and I will need a mix between Blade templates and Vuejs components.
Basically the requirements of the project state that in the customer pages we can only use Blade but in the admin pages we are free to use anything, so we will use Blade + Vuejs.
I know is possible to create a form in Blade, and then require or #include that form in any other Blade file. Is it also possible require that form inside a Vuejs component?
For example, Is it possible to do something like this:
<my-form-component>
#include('path/to/blade/form')
</my-form-component>
If you want just use vue js in blade template, you can definetely use,
Hope you aware that blade and vue share similar syntax {{ }} for variable interpolation, to avoid vue and blade conflicting, you should add # notations ex: #{{ .. }} so blade engine will skip it,
But if you want to use vuejs component and blade template mixing, you shouldnot do it..

how to uses ReactJS and Laravel

how to combine Laravel and React? I mean, Laravel uses blade for its view, how to change it to React instead of blade ? There have been so many Laravel and Angular tutorial, but I can't find any for React and Laravel?
Any references of Laravel and ReactJS tutorial ?
If you are using Laravel to build a REST web service (API), then you might not need Blade. You just return JSON data. Your React App can then make calls to the Laravel API for data and process it right in the browser. You don't need Blade for this.
You would use Laravel to provide the base view (index.blade.php) which would include the React JS app, but then after that all the views and routing would be handled by React.
Here's a link to get you started.
https://medium.com/#rajikaimal/laravel-loves-reactjs-8c02f8b9d1d5
I have created laravel reactjs starter project .. refer the github project below.
I am not using the mix api of laravel since I want reactjs app to be portable to any other server or standalone app
refer the link below
https://medium.com/#padmanabhavn/bringing-laravel-and-reactjs-together-8c970cb0f65d
This question seems old but I will still share my experience for others.
This tutorial and project sample may be found useful.
https://blog.pusher.com/react-laravel-application/
https://github.com/maarcz/taskman
As well as that, the solution below has worked for me in webpack.mix.js without using app.js to be mixed up with other requirements (laravel 8):
mix.js('resources/assets/js/react', 'public/js/reactJs').react()
in blade:
<script src="{{ asset('js/reactJs/react.js') }}"></script>

Resources