Mauro Benedito
Mauro Benedito

Reputation: 3

I must use server side code to my app interact with firebase/firestore?

I'm a little bit lost, I was reading the documentation on firebase and they have auth and other functions client side and server, what's the difference? I want to build a serverless web app. Can I do it all (auth, CRUDE) from the client?

Upvotes: 0

Views: 785

Answers (2)

Sculletbutt善
Sculletbutt善

Reputation: 460

Yes You can build a serverless app by using client side code only (example: swift + firebase Auth, Firestore, Storage etc).

However some feature or for security purpose you might need to write some cloud function code. Cloud function code are server side code which will never exposed on client side

Upvotes: 0

Frank van Puffelen
Frank van Puffelen

Reputation: 599956

Firebase provides SDKs that allow you to interact with its back-end services right from the client. This means that your (web) apps can read and write directly from Cloud Firestore, by using Firebase's JavaScript SDK for that.

You'll then use Firebase's server-side security rules to control what data each user can read and modify in the database. This typically means you'll ask your users to sign in, although this is not technically required.

Whether this is good enough to build your entire app without writing any server-side code, depends on the use-cases that your app covers. Typically I use Cloud Functions to run my server-side code without worrying about server administration, and I use it for:

  1. Operations that require sensitive data (e.g. API keys for a payment gateway), or for which the code itself is sensitive (e.g. cheat detection for games).
  2. Operations that require reliable computing power such as RAM, CPU, bandwidth or battery (e.g. scaling images).
  3. Operations that I only want to implement once, and that can wait until the user is connected to a network (Firestore continues to work on their local device when they're offline).

Upvotes: 1

Related Questions