How to Use react@16.8.6 or react@next in Laravel ?
step 1: create your laravel project with composer command
==> composer create-project --prefer-dist laravel/laravel blog
step 2: Install react in your laravel.
==> php artisan preset react
step 3: Install all the dependencies.
==> npm install or yarn install
step 4: Check, is it work?
==> npm run dev or yarn run dev
if everything is okay? go next else recheck those command.
step 5: go to in your project "package.json" file.
step 6: Edit this two line of package.json file.Set which version you want.
"react": "^16.8.6",
"react-dom": "^16.8.6",
step 7: Then again insall dependencies
==> npm install or yarn install
All the command part is over.
step 8: Go resources/views/welcome.blade.php
set ==> under the body tag crate a div and set id="example"
<body>
<div id="example"></div>
</body>
Everything is okay.
step 9: Run the laravel server and build react.
==> yarn run dev or npm run dev
==> php artisan serve
refresh your browser
It will be working .
Thank you.
Top comments (2)
you can use laravel with react as ui now? cool
yep