Nativescript & MySQL



I’m new to nativescript dev and I have good experience in developing in JS, HTML5 et PHP. The local database is good for many apps design but not for all.

I’m looking for information and example on how to use hosted MySQL database to work with my nativescript app. I have found this video which explain how to use node.js to connect to MySQL database.

If I’m not wrong, nativescript use node.js but this video doesn’t show/explain how to access an hosted MySQL database with nativescript.

I want to be able to login to a service and read/update/insert text information. At the end, If I also could update picture too, that would be great.

I have looked around google and youtube for such examples which are for me the basic of the basics service you may offer (like on an app like Tinder).

What I’m looking is possible or not?


Hey Omizu,

Is there a particular reason you would want your application directly communicating with the database? What do you think about using a remote service (backend) to which you send requests in text/binary format. Said service then takes the whole responsibility of writing to the MySQL database? That I believe is a better approach because you can abstract the communication API and not depend on 1 specific domain language, or a specific plugin to handle your remote database trips. You can also have all necessary checks, data validations in the backend, so that your mobile app will only serve as the Front End (client layer).

Please take a look at some good articles about n-tier architectures in Software, which I believe will help you understand what I am suggesting.


Hi Pete,

Thanks for your reply. I will check on those points you refer to and to answer your question, when I develop a website , I don’t use a n-tier actor to make my database operation. I mean : on one side I have the front (with the browser) and the back (asp or php) which allow me to work with MySQL. I don’t see why it could be the same with app because to me, the smartphone become the browser (with chrome or firefox or safari on it). Why the rest of the architecture should change. I don’t get the point :slight_smile:


That is what Pete is suggesting. Have the app communicate with asp or php to communicate with the database.


Oh ok, sorry I thought Pete point was to use another service.

So my question, as I was already aware to use asp or php to communicate with the database, is how do y communicate between the app and asp/php.

On website is use ajax/post to do so but I havn’t found any exemple of such communication protocol with nativescript. Does it exist?


Mobile devices have networking capabalities, so the next logical thing would be to make http requests (or what you called “ajax/post”) using either:


@Pete.K’s recommendation of http requests is a great way to communicate with your database. I use that through an api layer to communicate with my Database.


Thank you very much Pete for this details. It really help me :grinning: