Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do React & NodeJS work together?

Can you tell me more about the relationship between the two? I want to (for example) write a little tool which plays audio files on my raspberry pi. Would I then do the player and the players interface completely in React, and then just connect to node in order to get the actual files?

Or, more generally but the same thing, if I would want to write an application that does certain things (writes files, records audio, changes system settings etc.) that would all be done in nodejs, but if I want to have an interface I would use something like React?

I am a bit confused, but I hope this question is valid!

like image 704
George Welder Avatar asked Dec 27 '16 17:12

George Welder


People also ask

How do React works?

React uses a declarative paradigm that makes it easier to reason about your application and aims to be both efficient and flexible. It designs simple views for each state in your application, and React will efficiently update and render just the right component when your data changes.

How do you start a React?

Setting up a React Environment If you have npx and Node.js installed, you can create a React application by using create-react-app . If you've previously installed create-react-app globally, it is recommended that you uninstall the package to ensure npx always uses the latest version of create-react-app .


1 Answers

Node and React can be used together.

There is even the MERN stack that helps with that:

MERN is a scaffolding tool which makes it easy to build universal apps using Mongo, Express, React and NodeJS. It minimises the setup time and gets you up to speed using proven technologies.

See: http://mernjs.org/

But you can use React with any other Node framework, not only with Express. React can work with any REST API so whatever you use to build a REST API can be consumed by the frontend written in React.

Some other options include: Hapi, Restify, LoopBack. For more see:

  • http://nodeframework.com/
like image 176
rsp Avatar answered Sep 30 '22 13:09

rsp