TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Next.js and Python Backend?

3 点作者 funerr8 个月前
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 条评论

bbor8 个月前
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 ;)
cdaringe8 个月前
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 未加载
aosaigh8 个月前
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_puff8 个月前
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.
aristofun8 个月前
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?
datadrivenangel8 个月前
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.
Raed6678 个月前
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