← Back to Community
Is it possible to use Go for a backend with React for a frontend?
Profile icon
[deleted]

And if so, how would I go (pun not intended.) about this?

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Profile icon
xfinnbar
Comments
hotnewtop
Profile icon
xfinnbar

Yes, just put the generated HTML from your react bundle into a static folder and redirect all 404s to index.html.

Profile icon
[deleted]

@xfinnbar I guess this would work in theory, but is there a way to render pure react and not just HTML?

Profile icon
xfinnbar

@Martin025 No, because the browser can only understand HTML, not react.

Edit: The react dev server converts your react to HTML, CSS, JS in real time to simulate the execution of react code directly.

Profile icon
Coder100

@Martin025 react literally is a library not a language
you are going to have to compile the react to HTML.

(namely something like create-react-app)

Profile icon
[deleted]

@Coder100 true. So is there a way to connect (like you said) create-react-app to Golang?

Profile icon
Coder100

well
that's not the right line of thought

react can be treated as the frontend
and go, can be treated as the backend
you don't need to connect go, you write go to render the react. @Martin025