mysqldatabaseionic-frameworkionic-react

Connect to MySQL using Ionic Framework without api layer


Is it possible to connect to a MySQL database directly from an Ionic application without an integration/api layer?

All the answers I found online suggest to create API in php or nodejs, but I would like to develop a sql client and the whole point of the application is to be able to make queries directly from the client device.

I cannot use the node mysql library from client side.

I am using Ionic 6 React.


Solution

  • No, as noted by Mostafa Harb, you cannot directly access a MySQL database in the cloud from a device. You'll need to use some kind of API.

    The basic flow:

    The good thing about Ionic is that it is mostly framework-agnostic, so you can use any API you like.

    Personally, I use Drupal, which is a PHP-based CMS that has support for providing access to Ionic via REST, JSON:API, or GraphQL (or a mix of the three).