Ask coding questions

← Back to all posts
Is it possible to use Go for a backend with React for a frontend?

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

Answered by Coder100 [earned 5 cycles]
View Answer

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


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


@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.


@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)


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


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