Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why not making a React app without a backend?

A friend just asked me a question: Can I make a React app and connect to Mongodb without setting up an Express server? I couldn't answer the question, I'm used to using the frontend-backend-database flow but I can't think of a reason why it's not possible to skip the backend part. I'm not sure if I can install mongoose and interact with the database directly from React, but it seems reasonable to me, especially for simple apps that just fetch and insert some info from and into a database. I think it might not be a great practice because it requires extra computational work on the browser, is that right? Sorry if the question is silly, I'm new to the web dev world.

like image 210
csuarez94 Avatar asked Aug 08 '26 10:08

csuarez94


1 Answers

Can I make a React app and connect to Mongodb without setting up an Express server?

You probably can, but you shouldn't (unless it is only you who is ever going to use this app). If the database is exposed directly to the frontend, anybody can see and change anything, including wiping the DB.

like image 157
Sergio Tulentsev Avatar answered Aug 09 '26 22:08

Sergio Tulentsev