Add react to laravel

abelhorihuela profile image abelh ・1 min read

If you need add react in your projects of laravel this is very easy and simple.

1.- Create your app of laravel.
Alt Text

2.- Run this command in your path of project.
Alt Text

This command create configuration and base files of the first component resources/js/ & resources/js/components/Example.js, you need update Example.js

Alt Text

After this you need install all dependences for react
Alt Text

The next step is configure wildcard in your file of routes routes/web.php
Alt Text

And then you need create view with name app.blade.php on resources/views/ and add this configuration
Alt Text

This configuration will be enough to test our application.

For development mode you can run this commands in differents terminals:

npm run watch
php artisan serve

Build for production:

npm run prod

Source code: https://github.com/abelhOrihuela/test-laravel-react

Thanks for reading...


Editor guide