DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,673 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
abelh
abelh

Posted on

Add react to laravel

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...

Top comments (0)

Need a better mental model for async/await?

Check out this classic DEV post on the subject.

β­οΈπŸŽ€ JavaScript Visualized: Promises & Async/Await

async await