Is running a Golang backend with Next frontend a dumb idea?
Unanswered
Havana posted this in #help-forum
HavanaOP
It seems to me that this prevents Server Side Rendering.
11 Replies
Asian black bear
No, it does not. Your server-side Next.js code just fetches from your backend instead.
HavanaOP
Should I be using
pages
vs app
with a Go backend? Or is this a situation where the next.js server is running but calls to the Go app. [next.js frontend] <--> [next.js server] <--> [go server]
Asian black bear
The choice of backend does not affect which router you should use. The app router is generally recommended because it's modern.
Regarding your second point: yes, your Next.js server just calls the dedicated backend server as mentioned before.
HavanaOP
seems redundant to me but I don't know much
Asian black bear
You couldn't possibly SSR otherwise.
HavanaOP
what does SSR do vs an only React frontend? in documentation I see that it will not show a blank white page. it make sense to me that it would show aspects of the webpage that don't need to query any database, like user specific data. and then wait until that data is returned to create those elements
Asian black bear
Check out this interactive example from Remix by slowly scrolling down: https://remix.run
In particular this section:
In particular this section:
In short: everything is prerendered server-side and it is displayed in one single request. SPAs do multiple requests back and forth and fetch/render client-side.
The latter is a terrible user experience for certain use cases and has downsides when it comes to SEO etc.
HavanaOP
ah ok makes sense. kinda surprising without remix would 'block' the other requests or do them sequentially or whatever. and I assume the extra api calls from the next.js server to the go server wouldn't take much additional time since they're on the same machine