7

I am building a react native app for mobile on my MacBook. I want to connect MS SQL server where is installed in VMware Fusion virtual machine. How can ı connect my MS SQL server on my MacBook?

2 Answers 2

14

You can't. Or more appropriately, you shouldn't. React is a front end library and it should connect to a backend service such as REST API which then connects to MS SQL database.

The reason why you shouldn't is simple. Front-end libraries have all their code running in the client's browser which allows the user to view the source. If the user can view the source and there is a database connection in the source, he'll be able to connect directly to your database.

By using a REST API, you can hide all database connection information on your server to which the user has no access.

Sample tutorial: https://dzone.com/articles/aspnet-core-crud-with-reactjs-and-entity-framework

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for answer but this site develop for visual studio. I want to build javascript api layer? How can ı do this ?
For that you would use node.js: codeburst.io/…
5

A little too late but just in case someone trying to find a way to directly access an MSSQL database from his react-native app like I did.

https://github.com/davidstoneham/react-native-mssql

I still agree with @bobek's answer that it isn't the best approach but handy when you don't want to create an API layer and have direct access to the database.

1 Comment

Thanks for the answer man. Sometimes we just want to test our apps before moving onto API creation. Sometimes it's for a small department to be used by only a few people only on the intranet. Not everything goes into production like that.

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.