TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Next.js and Python Backend?

3 pointsby funerr7 months ago
Given that python is leading the charge in terms of ML/LLMs, I still want modern react features ( next.js) - what are best practices around combining the two?

7 comments

bbor7 months ago
I’m doing this with Quart on the python side and prisma for both (there’s a python prisma adapter! Crazy world) and I’ve been enjoying it. Biggest framework hurdle so far has been that next.js doesn’t have native support for Websockets, which is something you’re pretty likely to want if you’re bothering to run two full server processes. It’s not hard to implement them manually, but it isn’t as nice as just sticking everything on Socket.io.<p>Also, obviously, you should only do this if you have a really solid architectural vision for separating concerns; any requests that need to hit python naturally loose all of Next’s fancy optimizations for server&lt;-&gt;client data passing, other than basic caching I guess. If you just want react itself, I’m pretty sure there are less framework&#x2F;resource intensive ways to deliver SPAs and cut out the node server altogether - but that’s something of a guess.<p>Best of luck! The hardest part is remembering to switch between typescriptSyntax and python_syntax ;)
cdaringe7 months ago
Using next strictly for the front-end feels like a slight miss. It works fine to do so, but its strong suit is being a full stack react framework. If your app needs a server and you opt out of next, you sacrifice the common config model, isomorphic pages and data loading patterns, integrated api routes, optimized route&#x2F;path browser bundles, …more. I get that folks like python, but if you’re already paying the cost of one major tech framework in your project, you should seriously consider if you really want to pay for two (pay used loosely for cost of tech ownership). Next can and will do support your BE needs, presuming you’re not deeply reliant on some biz value from company python packages
评论 #41874126 未加载
评论 #41870919 未加载
aosaigh7 months ago
I use Next.js with Django regularly. Just set up Django as a REST API only. Have Next.js talk to the API either at build-time or run-time, whichever suits your use-case. You could even proxy calls to your backend server via Next.js server-side functions if needs be.<p>I find the full-stack-in-one-codebase approach that Next.js takes very hard to work with. It becomes hard to know what is &quot;frontend&quot; and what is &quot;backend&quot;. Mixing server-side components with client-side components is a mess. So I stick to a traditional SPA approach: front-end static site and back-end REST API server.
siamese_puff7 months ago
Don’t listen to the lovers of Next saying you need both.<p>Bundle the client and serve it from Python. Use Python for APIs that you call from the client. You can bundle a server and client bundle optimally, do SSR within Python and hydrate the client with the client bundle.
aristofun7 months ago
Python on backend is not in any way superior to node (the opposite if anything) — then isn&#x27;t it better and cleaner to isolate all AI python bells and whistles inside some sort of a balck box API?
datadrivenangel7 months ago
Currently doing a poc with NextJS frontend and Python Flask backend. Doing it all through vercel makes it pretty easy. If I was self deploying, I&#x27;d probably do FastAPI instead.
Raed6677 months ago
Why do you need Next.js compared to a static web app with React+Vite ?<p>Do you care about SEO &amp; serve-side features ? If you already have a backend with Python, then maybe Next.js is redundant