DEV Community

Bret
Bret

Posted on

can I just use React + ExpressJS? Or React + MongoDB?

Do I need ExpressJS in a retail site? Or how about NextJS?
I’m familiar with Sqlite3, and I’m eyeing MongoDB.

Top comments (5)

Collapse
 
khorne07 profile image
Khorne07

React is a front end library for Single Page Applications. It only manage your UI. You can use Express or any other backend framework for handling your application logic and database conection. Actually you may be interested in MERN stack who undestands for Mongo + Express + React + Node. Is a combination of JavaScript frameworks and libraries that can help you develop real good apps using js for all.

Collapse
 
yobretyo profile image
Bret

Ok 👍 so express is the middle part for handling the dB?

Collapse
 
khorne07 profile image
Khorne07

Exactly. Express handles the request from your front end and retrieves data from your database to your UI or sends the data from your UI to your database. It also do more staffs but basically that is the way it works

Collapse
 
miicha profile image
Miikka Saxlund • Edited

You should never make database queries directly from the front end, as this exposes your database to malicious activities. It means that you will need some kind of a back end service handling queries to the database. This is what Express and Mongoose is great for. Express handles all the end points for HTTP-requests made from the React site, while Mongoose handles the queries to the MongoDB without exposing the database. In other words, Express application acts as a m̶i̶d̶d̶l̶e̶w̶a̶r̶e̶ middle tier between the website and the database.

Collapse
 
priyadarshikunal profile image
Priyadarshi Kunal

Middle tier rather than middleware.