Search code examples
firebasefirebase-realtime-databasefirebase-storagefirebase-hosting

Custom Firebase API for Apps


I am developing a new application that integrates into Firebase.

My question is whether I should have the application connect directly to Firebase Database? Or should I develop my own custom API using Node.js and have my app connect to those API's? Or is it OK for my app to connect directly to Firebase Database?


Solution

  • The Client SDKs (JavaScript, Android, iOS) are especially made for directly connecting your app to Firebase services (Databases, Cloud Storage, etc.).

    You normally combine them with some security rules, either to manage access control or to control the data that is written to the database.

    If you have specific needs that cannot be implemented through the Client SDKs (and security rules) you could very well use you own APIs using the Node.js SDK: for example, implementing you own authentication/autorisation mechanism, implementing a complex business logic to verify data that is coming from the client app, or a business logic for transforming data that you don't want to expose in the front-end (aka "Secret sauce"), etc.

    Here is an article from Doug Stevenson (Firebaser) comparing Client SDKs and Cloud Functions to write to the database that you should definitely read: using Cloud Functions is similar to implementing your own APIs in Node.js (Same language, environment that you manage).