DEV Community

Cover image for react@16.8.6 or react@next setup in Laravel.
Md. Mustak Talukder
Md. Mustak Talukder

Posted on

react@16.8.6 or react@next setup in Laravel.

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)

Collapse
 
salimkafin profile image
kafin

you can use laravel with react as ui now? cool

Collapse
 
mustaktalukder profile image
Md. Mustak Talukder

yep