0

I am trying to link my mysql database with my react native application similar to React Native and Mysql Connection. The question I have is probably dumb but I cannot find an answer to it so.... how do I get my backend node js script which makes requests to my database to open automatically and run in the background as soon as the react native application is launched. I don't want the user to need to somehow open this script separately or run it on a computer on the network, I want to be able to use expo go on my phone to run my react native application and the node js script to automatically run in the background so I can grab data from it in my react native application. Is this even possible?

4
  • Where is your mysql database kept? And is there a special reason why you'd want to run a node server locally on a client device? The "normal way" of doing things is to host your database and node instance on servers accessible through the internet, and a client app (ie your React Native build) will communicate with them via API's. Commented Feb 8, 2023 at 2:43
  • This is extremely useful information. I am hosting the mysql database on a free AWS RDS server, Do you have any recommendations how I would set this up if I am using aws Commented Feb 8, 2023 at 2:52
  • Right, so consider most "apps" broadly have this structure: (A) client, (B) server, (C) database. (A) is your front-end which could be a mobile app or website server by your server. This is React Native in your case. (B) is just "the server", which would serve website files (in case of a website) and as a proxy (ie "go-between") between clients and the database. This would be a node.js instance. (C) is just "the database" and is where you keep data. This could be any technology including mysql. It requires it's own server most of the time. Commented Feb 8, 2023 at 13:46
  • (A) could talk to (C) directly but it's much better if there's a "policeman" in between, which would be (B). So your node server will chat to both (A) and (C). This means in theory the database really only needs to be accessible by your node server. (B) would have to be publically accessible so that (A) can reach it from any device, anywhere. Larger more complex apps will multiply everything: multiple clients, servers, cache layers, fallbacks, etc. Whatever the case, you need to read some articles on "creating-and-deploying" React and React Native apps. Commented Feb 8, 2023 at 13:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.