How can I use NodeJS with React?

I am learning React and I would like to create a socket.io chat app with it but I am unable to due lack of my knowledge in terms of making NodeJS work with React in a Glitch project. Any ideas?

Yea, setting up the bundler can be tricky sometimes, luckily glitch has got a neat template to get ya started. It should be in your new project menu, also it’s a .new shortcut.

Happy Glitching (hey moderators can we get a glitch logo emote here?)

Yeah but how do I set up nodejs backend?

For that I’d suggest looking up a guide on using webpack or some other bundler with react. The basic idea is to have an express/fastify server with the static file serving middleware so it behaves similar to the builtin static server, then put in whatever backend logic you need like adding socketio
also glitch, I typed in the glitch dot new shortcut for react but discourse seems to unshorten the link to glitch.com/edit/

1 Like