As opposed to useAuthState in react-firebase-hooks
(which doesn't work with gatsby builds),
this is designed to work with gatsby-plugin-firebase
.
Requires React
and firebase
Usage example:
import firebase from "gatsby-plugin-firebase"
import useAuthState from ...
function MyComponent() {
const [user, loading, error] = useAuthState(firebase); // NOT firebase.auth()
// ...
if (loading) return <p>Loading...</p>
if (user) return <p>Hi, {user.displayName}!</p>
if (error) //handle error
}
Hmm, breaks for me during build.
WebpackError: TypeError: _lib_firebase_useAuthState__WEBPACK_IMPORTED_MODULE_5 ___default(...) is not a function