Search code examples
mongodbflutterdartmongo-dart

(dart / flutter) using "mongo_dart" for user authentication


I was developing a medical application (meaning I have to store patient information) with flutter as the frontend and mongoDB as the backend. Is it safe to use the "mongo_dart" package for signin / signup? Or must I use another package such as "http" and build a backend?

This is my first time building an authentication system, so I am really lost. When it is possible to use "mongo_dart" for authentication, how can I do so? Will I need to add a separate cluster for users, such that when an email and password matches I will grant user access?


Solution

  • First of all MongoDB is a database, it isn't a backend service. You can only store your data there.
    The description of the "mongo_dart" starts with this sentence:
    "Server-side driver library..."

    So this package can be used for creating an API in dart. And also it is highly recommended to have an own backend service for your app.
    So you can use Flutter for the frontend and MongoDB as your database service. Now you have to choose a language for backend, such as Node.js, Python or you can go with Dart as well.

    And with your own API you could have an own API url, such as like: "https://myownpage.com/api/*". And in your Flutter app you can call this route for various actions: logging in, querying data and so on.

    So it is absolutely fine to use all the things that you mentioned, but you have to create a backend application for the magic happening behind your mobile app.