Firebase Context
There are some cases where you need to access the Firebase SDKs directly. For example, if you
want to use any method from firebase/auth to log in your users. In this case, you
can use the methods we provide.
Why?
This might look weird to you because you would say: "Why can't I just import the Firebase SDKs I put in the
FirebaseAppcomponent?". You can, but this means you have to create a specific file to define your SDKs and then import them inFirebaseAppand everywhere else. The goal here is to avoid this and let you just define the SDKs once in theFirebaseAppcomponent and then use them everywhere else with our methods that use the Svelte context API.Methods
getFirebaseContext()
getFirebaseContext(sdks: FirebaseSDKContext)is a method that returns the Firebase SDKs you defined in theFirebaseAppcomponent. You can use it to access the SDKs directly.updateFirebaseContext()
updateFirebaseContext(sdks: FirebaseSDKContext)is a method that updates the Firebase SDKs you defined in theFirebaseAppcomponent without replacing the old ones. You can use it to define new SDKs directly.We do not recommend using this method nor updating the Firebase SDKs at all as it can lead to unexpected behavior.
Types
FirebaseSDKContext
interface FirebaseSDKContext { auth?: Auth; firestore?: Firestore; rtdb?: Database; storage?: FirebaseStorage; remoteConfig?: RemoteConfig; }