Is creating a Django backed reactjs (like nextjs but use django) a bad idea?
Hi folks,
I am a frontend software engineer (reactjs, nextjs) and have been working on python for AI related stuff for quite a few years.
I am wondering if creating something like nextjs but use Django as backend could be a bad/terrible idea or a good idea. What do you think? Thanks.
Here are the reasons behind this idea:
1. React (Nextjs) is wonderful for frontend while pythong works perfect for machine learning (at backend).
2. To demo or dev machine learning or AI related stuff we need some easy to start front-end framework. I have tried gradio but still wish the frontend could be replaced by reactjs.
3. Yes it's possible to create reactjs + Django app but think about reactjs + nodejs if comparing with nextjs.
What do you think?
18 comments
[ 2.6 ms ] story [ 56.2 ms ] threadThat said, you can accomplish some good things with Django.
Ultimately this all boils down to 2 things:
* your/your team's proficiency in the tech
* using the right tool for the job
I am not sure if you're trying to replicate some specific NextJS feature or if you're just asking what tech to use for your backend? If it's the latter, Django/Flask/FastAPI will do just fine. More than fine. It's boring, but it works.
My go to would be a simple REST API backend + ReactJS on the frontend. If you want to start mixing server side generation then there is a way forward but it depends on the nature of your app.
Start simple. Keep it boring.
Django and Next are both very opiniated and can basically achieve the same results.
Point by point: "1. React (Nextjs) is wonderful for frontend while pythong works perfect for machine learning (at backend)."
-Nextjs is a fullstack framework. You can use python with lighter backends too, for example Flask or Starlette. What benefits would Next bring is you're planning to use django?
"2. To demo or dev machine learning or AI related stuff we need some easy to start front-end framework. I have tried gradio but still wish the frontend could be replaced by reactjs."
-If you have a good grasp of React, go with it. Nextjs however is a lot more complex. You could also work vanilla for the front.
"3. Yes it's possible to create reactjs + Django app but think about reactjs + nodejs if comparing with nextjs."
-If you're talking about plain React, then whatever backend you suits your need (if ML-things, probably a Python / Go based one) will do. If you're planning to use Nextjs, it would make more sense to do as much as possible in Nextjs and host a lighter api / backend / lambdas for ai-stuff. Using express means using JS too in the backend. This isn't an advantage necessarily – HTTP doesn't care about the language of the backend.
Is a little bit tedious to set everything together, but other than that, is fine.
You most likely will lost some good DX stuff like same types in front and back (like with using tRPC and the like), but in general is pretty good: logic in python, UI in js/ts.