5

how to combine Laravel and React? I mean, Laravel uses blade for its view, how to change it to React instead of blade ? There have been so many Laravel and Angular tutorial, but I can't find any for React and Laravel?

Any references of Laravel and ReactJS tutorial ?

3
  • 2
    Laravel as an API and React as the front-end page Commented Jun 29, 2016 at 11:40
  • so, how to get the data from Laravel API ? and how about the routing ? Should I use pure javascript for the routing ? Commented Jun 29, 2016 at 11:42
  • No, you should use react-router. I would suggest starting with React, once you got your app working you can start using real data by creating an API in laravel Commented Jun 29, 2016 at 11:45

3 Answers 3

4

If you are using Laravel to build a REST web service (API), then you might not need Blade. You just return JSON data. Your React App can then make calls to the Laravel API for data and process it right in the browser. You don't need Blade for this.

You would use Laravel to provide the base view (index.blade.php) which would include the React JS app, but then after that all the views and routing would be handled by React. Here's a link to get you started. https://medium.com/@rajikaimal/laravel-loves-reactjs-8c02f8b9d1d5

Sign up to request clarification or add additional context in comments.

Comments

0

I have created laravel reactjs starter project .. refer the github project below. I am not using the mix api of laravel since I want reactjs app to be portable to any other server or standalone app

refer the link below

https://medium.com/@padmanabhavn/bringing-laravel-and-reactjs-together-8c970cb0f65d

Comments

0

This question seems old but I will still share my experience for others.

This tutorial and project sample may be found useful.
https://blog.pusher.com/react-laravel-application/
https://github.com/maarcz/taskman


As well as that, the solution below has worked for me in webpack.mix.js without using app.js to be mixed up with other requirements (laravel 8):

mix.js('resources/assets/js/react', 'public/js/reactJs').react()

in blade:

<script src="{{ asset('js/reactJs/react.js') }}"></script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.