Hacker News new | past | comments | ask | show | jobs | submit login

If you're doing server-side rendering, why do it in React SSR instead of Django templates?

I've seen this pattern a lot recently but haven't figured out what the extra complexity gets you




I haven't used this particular framework, but having type safety in React through writing TypeScript, generating bindings to the backend so those are typed as well.

There's also a _ton_ of preexisting React components you can generally drop in and use, which is less true these days with something like a Django template.

You also have the option of doing SSR and then doing more dynamic stuff on the client side, as a sort of optimization (and plain better user experience than making _more_ server requests to get the initial page state loaded).


Thanks for taking the time to reply, but I'm still not really understanding the benefit.

Type safety is incredibly important if you're lots of logic in a language, which is why TS is great for SPAs. Does the type safety of TS get you anything if you're just doing SSR with not a whole lot of logic in TS? All of your application logic will be on the Python side of things.

>You also have the option of doing SSR and then doing more dynamic stuff on the client side

Isn't this just the old-school way of doing things before SPAs came around? i.e you render the page on the server and then add dynamics features using JS. I think the new way of doing this is with htmx, hotwire, etc.


I think the biggest benefit of SSR is you get the first page fully rendered out (good for SEO), and beyond that page the react SPA takes over by doing all the cool client side stuff like routing and what-not.

The biggest benefit for SSR in my opinion is SEO + first load is fast because its already generated. After that though, its just the plain old SPA experience.


It's because React (and other SPA technologies that also happen to work with SSR) is all the buzz. It doesn't actually necessarily make sense. The risk to a project is usually NOT the technology chosen for frontend.

Django templates are perfectly fine as long as you leverage template tags the way they were intended.


I would agree that "Django templates are perfectly fine"... until: https://www.reactivated.io/documentation/philosophy-goals/#u...

Of course there's many ways around this, but doing them in a declarative, type-safe way is not trivial when using Django templates.


Given that example, would you say using SSR with React to add bits of dynamic-ness is directly comparable with using templates + hotwire/htmx?

Or is it an apples to oranges comparison?


It's very similar, except hotwire/htmx won't give you server rendering. It's not that big a deal if it's just small snippets.

This does make testing a lot easier, as the server response is identical to the hydrated client.


A hypertext approach such as HTMX in fact does give you server rendering, since you send to the client a normal SSR page with some extra annotations that add SPA features.

For React, SSR is secondary. For HTMX, it is primary.


There's a lot of good advice in that article. I liked the part on cookies in particular. You rarely read that anywhere.


You can use the same templates on the backend and frontend. That may not matter to you, at least not now, but it's a great reason in many contexts.

Personally I find JSX to be a terrific templating system, much better than anything like Django's, but if you're familiar with both and prefer Django's, this benefit does not apply to you!




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: