React Native, React Native Web
yarn add @datagee/elements
Securely store your firebase configuration details object and import that into your component. How you do this depends on your project and build settings.
For most users, storing the configuration in a file and adding it to your .gitignore is a sufficient configuration. Assuming you have an object like:
firebaseConfig = {
apiKey: "your_api_key",
authDomain: ...,
...
}
Easily add cloud services to your project like this:
import React, {
useEffect,
useState,
} from "react"
import {
DGFirebase,
} from "@datagee/elements"
const cloud = DGFirebase(firebaseConfig)
const YourComponent = () => {
const [user, setUser] = useState(null)
const signInAndDoStuff = async () => {
const resp = await cloud.anonymousSignIn()
const userData = await cloud.read(
"YourCollection",
resp?.user?.uid,
)
console.log(userData)
}
useEffect(
() => {
signInAndDoStuff()
}, [user]
)
return (
<>
{/* Your component */}
</>
)
}
Support for AWS Amplify and offline caching for Firebase coming soon!
For more information on this library, please see the documentation.
Generated using TypeDoc