2



I'm learning ReactJS and I already have experience with Django and DRF. My aim right now is to build a rather simple web application based on a Django backend and a ReactJS frontend. (Later on, when the web app is done, I'll tackle React Native).
I've been reading tons of documentation but nothing has sorted out the question:

What is the best approach to integrate a Django backend with a ReactJS frontend?

Should I keep them separate and connect them or should I mount ReactJS inside the Django application? Which one is the best-suited approach, taking into account maintenance and further development?
Thank you very much! Any opinion/hint will be appreciated.

1

1 Answer 1

1

My approach would be make an app called frontend or anything you like in Django, then all of my React code will be placed inside that app. You will also need webpack to bundle your React code then with collectstatic command Django will collect all the static files so it could be served. You can find the tutorial here

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

3 Comments

Thank you for your answer! My doubt is: in case I want to develop other frontend apps that uses the same backend (such as a mobile app with React Native), will the approach suggested still be ok? Or would it be better to completely separate backend and frontend?
@Giulia Sure ! REST API could be consume from anywhere, mobile apps or web apps it doesn't matter. The reason I choose to place the React code inside Django is because I can reduce from 2 repos to 1 repo only. And for some reason if you still want to separate them, it's completely fine.
Thanks! For some reason it seemed to me that separating them completely was better in terms of flexibility and future development, but from your answer I can see that's not the case. So I'll have React inside Django which is likely to be a little easier right now. Thank you very much!

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.