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.


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:

  • Ionic app authenticates to the API if necessary.
  • Ionic app uses Axios or Fetch to use the API to query the cloud database.
  • The API returns the response in a format the Ionic app understands.

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).

Answered By – Patrick Kenny

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published