-1

I want to develop mobile applications using React Native for Android and iOS.But I don't know how I can connect SQL Server. Is it possible or not? If it is possible how can I connect? I read that it is possible but for only Android. If it is for only Android, what am I going to connect db for iOS? Is there anyway for connect React Native with SQL server database? (or any tutorial?)

emmy
  • 1
  • 1
  • 3

3 Answers3

0

Yes, you can use SQL, Postgres, Mongo or any DB really.

You'd need to provide a backend of your choice using either node, php, python and etc. This will then communicate with your SQL server.

Other than that, nothing really changes on the front end other than pointing your API calls to your server and ensuring your info.plist allows for localhost or other APIs to communicate with it.

Info.plist

   <key>NSAppTransportSecurity</key>
    <dict>
      <key>NSExceptionDomains</key>
      <dict>
        <key>localhost</key>
        <dict>
          <key>NSExceptionAllowsInsecureHTTPLoads</key>
          <true/>
        </dict>
      </dict>
    </dict>

Here is a repo I've built that demonstrates how a react-native app can communicate with a node server and a mongo database. Maybe you can find some inspiration there.

richTheCreator
  • 1,318
  • 1
  • 12
  • 11
0

Sql Server does not support what you are trying to achieve. Check this answer

MSSQL server connection libraries are not client-side javascript >libraries. There is absolutely no way you can make TCP SQL connections >from a web browser, even if you wrote your own library.

For security reasons, you would never want to allow client-side access to >the SQL Server. You need to spin up server-side environment (e.g. >Node/Express) to expose an API to the client applications.

Community
  • 1
  • 1
Nisan Coşkun
  • 516
  • 7
  • 15
0

If you're looking for a plugin that connects to a host server, then you could use react-native-mssql to connect to a server. But if you're going to use a local file to store your data, react-native-sqlite is better.

Crypticsy
  • 760
  • 2
  • 7
  • 18