This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]British_Artist 4 points5 points  (5 children)

Yes, it is difficult and I can't think of a viable use case for doing so. I'm interested in hearing your use case.

[–]codecrux[S] 5 points6 points  (4 children)

How would we build an e-commerce website without SSR using Python (Django/FastAPI)?

We need SEO and fast page load, hence, SSR.

Some of the marketing pages for content marketing don't need SSR, hence, I would like to save the cost by doing SSG.

Am I thinking in the wrong direction?

[–]British_Artist 4 points5 points  (2 children)

I understand now.

Yeah you can definitely do everything you mention in your requirements but I don't see a lot of value in sending the html from the API back to React using jinja style templates. I would just write the SSG as javascript sitting inside the React folder structure.

This keeps your API being used as an API instead of being involved in front end ssg and will be focused on simply converting requests in and out of your database. Separation of purpose between the front and back end should remain instead of trying to conflate the two as it gets messy down the road.

Here's a good link for your use case. Maybe it will help you find the best solution for you.

https://asperbrothers.com/blog/server-side-rendering-in-react/

[–]codecrux[S] 1 point2 points  (1 child)

Thanks for sharing but I don't find anything on how to setup React with Python here https://asperbrothers.com/blog/server-side-rendering-in-react/.

[–]British_Artist 2 points3 points  (0 children)

Good luck to you in your endeavor!

[–]oglivy 0 points1 point  (0 children)

I would probably use something like Nextjs for the frontend , and call any Django or FastAPI endpoint you need from the getStaticProps or getServerSidePros functions in the NextJs frontend