4

How I can combining laravel and create-react-app kit?

I want to change the entry point from root/react/public/index.html, to root/resources/views/index.blade.php, how can I do this without using npm run eject?

Thank you!

2 Answers 2

1

I know it's a question from two years ago, but in case someone stumbles upon this in search for answers, it is now possible to use Create React App in Laravel: https://github.com/mjsarfatti/create-react-app-laravel/

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

1 Comment

It should work with 5.5, since the folder structure is pretty much the same as 6. I haven't tested it though. If you want to give it a try, maybe make a copy of your project and try to install CRAL there? Remember that the /public folder is wiped out and recreated on every build, you can refer to the docs for a detailed explanation on what happens.
0

You basically need to copy the contents from index.html to index.blade.php and make sure to update the app.js and app.css paths so they point to the correct paths

However, with this approach you will have issues using the full set of features that react offers when served via node.js (like react-router for example) so your best bet for any real like application would be to use react with node for frontend and then connect it to Laravel via a REST api to make backend calls

2 Comments

I just tested it using react-router and it works fine.
Ok with separating both projects @Tadej, but what if we need to host them in the same server (most common situation)? How would Laravel routes be and where within the Laravel directory structure would fit the whole create-react-app project?

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.