Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

scanf6's avatar

Using blade template data in react js component

I would like to use React js as a front-end for my laravel project . So i did the preset with:

php artisan preset react

Now i would like to know, how react component should be implemented in my blade views so they can access data passed to those views via controllers...

For exemple, in my homeController i pass some data:

return views('theview')->with('datas',$datas);

In theview.blade.php i can access them like this: {{ $datas }}

but how can i use this to update react component?

0 likes
2 replies
jlrdw's avatar

Have you taken any react tutorials from their site. Js in the way you describe you want to manipulate some fields, or divs, or whatever, after the view is loaded.

1 like
ejdelmonico's avatar

You don't need to use Blade views. Just use your React components in a React page template. It is really easy to do. As jlrdw advises, watch some React tutorials. If your goal is to randomly add JS components into Blade files, I would use Vue for that as it is better suited.

1 like

Please or to participate in this conversation.