I already built a CMS website using ASP.NET MVC with SQLserver 2014, and now i want to develop it into a mobile app using React Native, that I've been learning and playing with it's components for months now, but I don't know how connect the app with SQL server database. Is there anyway or solutions for connect React Native with SQL server database?
3 Answers
It is possible to connect a react native app with a remote MSSQL database using the react-native-mssql plugin (Android only at the moment).
Although it is best practice for security and performance to create an API interface there is nothing stopping you from connecting directly to the database if this suites your scope better than the API
Comments
You will have to create some sort of interface/API. The REST approach might be the correct one for your use case (manipulating data in a database).
Directly connecting to a SQL database from a mobile device is not recommended as the internet/network connection of a mobile device is prone to error and latency.
7 Comments
I would highly recommend you to make an API. The following points should explain you why:
- Security (create an API with tokens or auth)
- Error handling (your API should detect errors and send the correct headers)
- Reusability (what if you want to connect another app or website to the database?)
- Performance & API Management (you can control accesses and make statistics)
Once your API is finished, you can use it everywhere (fetch, axios, ...).