DEV Community

Cover image for How using React in a Laravel application - Tutorial

How using React in a Laravel application - Tutorial

Lesly Villalobos on July 25, 2019

Reactive applications are a big part of the web world, that's why it is necessary to use the latest technologies to deploy. Laravel had integrated...
Collapse
 
lucasca95 profile image
Lucas Camino

Hello, everyone!
Just wanted to say that in Laravel ^7.x to set your environment ready for a React development you should run

 composer require laravel/ui
 php artisan ui react
Enter fullscreen mode Exit fullscreen mode

Thanks for the post! It was really useful ;) !

Collapse
 
lordjack profile image
Jackson M

This video talks about another way to integrate with React and Laravel

youtube.com/watch?v=ie1yKbqkUFs

Collapse
 
karlkras profile image
Karl Krasnowsky

English version?

Collapse
 
imtridevsharma profile image
im-tridevsharma

Right 👍

Collapse
 
hominini profile image
Byron Pérez

is csrf configuration needed? because I have error with that, thanks

Collapse
 
lvtdeveloper profile image
Lesly Villalobos

Please, add this to your welcome.blabe file:

Collapse
 
yutakayoshida1 profile image
yutakayoshida1

now i have many problem in your article.
if you can teach me, please help me.

Collapse
 
yutakayoshida1 profile image
yutakayoshida1

Hello
how are you?
i am yoshida from japan.
can you explain in detail for me?
thanks.

Collapse
 
lvtdeveloper profile image
Lesly Villalobos

Please, add this to your welcome.blabe file:
thepracticaldev.s3.amazonaws.com/i...

Collapse
 
maximruslan profile image
BlueBamboo

i made laravel and react project.
but there is an bug.
if i click button, page is working well.
but if i refresh page, it is not working.
"don't found page"
I think it happends because route manage.
so if i refresh page, project find this route in web.php in laravel.
But there isn't this route there.
because it is react route.
I think you can understand my explain because you are react and laravel developer.
So how i can fix this issue?
Thanks.

Collapse
 
lossez profile image
Rayha • Edited

need help, Command "preset" is not defined. when i run php artisan preset react

Collapse
 
cliffchristianson profile image
cliffchristianson • Edited

You've probably fixed this but for others with the same problem, the preset command was removed in Laravel 7, you will now want to use

composer require laravel/ui

php artisan ui react

auth and some other guys are here now too

Collapse
 
adelinghanaem profile image
Adelin

But documentation still shows php artisan preset react command !

Collapse
 
arbazargani profile image
Alireza Bazargani

first of all, thanks for article.
i got situation,
what if we want to use react in deployed project?
i mean that application is not new & clean.

cause i tested and nothing happens!

Collapse
 
lvtdeveloper profile image
Lesly Villalobos

It may be a caché problem.
Try this:

php artisan cache:clear
php artisan view:clear

Collapse
 
josealex27 profile image
joseAlex27

Hi, do you have deployed this app? cause im trying with mine and nothing happens!
thanks!

Collapse
 
josealex27 profile image
joseAlex27

im using cpanel to deploy the project and it doesn't work!

Collapse
 
vieckys profile image
Hemant Sankhla

Best and easy solution to get started.
Thanks.

Collapse
 
vishnu8742 profile image
Vishnu :)

Hey, Thanks. :)

Collapse
 
lvtdeveloper profile image
Lesly Villalobos

:3 thanks to you

Collapse
 
khyn profile image
Khyn Antoque

Amazing! Thanks :)

Collapse
 
lvtdeveloper profile image
Lesly Villalobos

;)

Collapse
 
yoyooo profile image
yoyooo

This is so helpful. Thanks!

Collapse
 
lvtdeveloper profile image
Lesly Villalobos

Thanks to you :)

Collapse
 
sobec201 profile image
carlos • Edited

Amazing job, so clear, thank you so much for you time and share your knowledge, and also you're so beauty ^^

Collapse
 
picwellwisher12pk profile image
Amir Hameed

thanks

Collapse
 
arahman1783 profile image
Abdelrahman Elhusseiny

Thanks for this useful article

Collapse
 
imtridevsharma profile image
im-tridevsharma

Guys tell me your opinion on should I use laravel react scaffolding or a separate react ui for frontend?

Collapse
 
lftroya profile image
LFTroya

How can you pass props to the component?

Collapse
 
rohitsuthar profile image
Rohit Suthar

Thanks for sharing these nice articles!!

Collapse
 
jorge170909 profile image
jorge170909

Hi Lesly, thanks!. Do you know how can I use Typescript instead JS files?

Collapse
 
galih56 profile image
Galih indra • Edited

This is a great article.

How to install redux or any packages?

and also how to deploy mono react+laravel if my server doesn't have node.js like cpanel?

Collapse
 
vsfarooqkhan profile image
Farooq khan

Is that npm run dev required for every time

Collapse
 
lvtdeveloper profile image
Lesly Villalobos

You can use "npm run watch" instead of "npm run dev" because that run scripts from package.json when files change.

Collapse
 
zebedeu profile image
Marcio Zebedeu

thank you

Collapse
 
vsfarooqkhan profile image
Farooq khan

I'm facing an error while sending the csrf_token() to react js . I have a seperate react js code which included inside blade file . How can I send the csrf_token to controller via axios ?

Collapse
 
babarkhann profile image
Babar Khan

Can we use React well as Vue with Laravel?