Create-react-app: Any way to add any backend tech to the app? Express, Mongo, Mysql etc..

Created on 3 Jan 2017  路  1Comment  路  Source: facebook/create-react-app

Hi I want to create a MERN app out of create-react-app, but I am running into a dilemma since the bundle launches the app on a server. I want to connect the app to mlab using Mongoose and set up some routing for the db. Is that possible?

Any direction or advice would be greatly appreciated.

Peter

PS I tried calling my mongoose model directly inside my src file, because it seems that everything in that folder is served over a server. The error I got was pretty interesting. I discovered what a disaster it is to try to compile MongoDB, which is all ready in C. Needless to say it was a late night. Anyway, any advice would be greatly appreciated. Thank you.

Most helpful comment

PS I tried calling my mongoose model directly inside my src file

This wouldn鈥檛 work. Create React App bundles your JS in files to be executed by the browser. There is no server side component to it: it just produces HTML+JS+CSS which you can serve any way you like.

For example integration with Express or Rails, please check these articles:

https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/
https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/

I hope this helps!

>All comments

PS I tried calling my mongoose model directly inside my src file

This wouldn鈥檛 work. Create React App bundles your JS in files to be executed by the browser. There is no server side component to it: it just produces HTML+JS+CSS which you can serve any way you like.

For example integration with Express or Rails, please check these articles:

https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/
https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/

I hope this helps!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wereHamster picture wereHamster  路  3Comments

DaveLindberg picture DaveLindberg  路  3Comments

alleroux picture alleroux  路  3Comments

dualcnhq picture dualcnhq  路  3Comments

stopachka picture stopachka  路  3Comments