react-hooks-firebase-auth
v0.2.2
Published
Library for easy handling of Firebase Authentication, complete with provider token related events
Downloads
4
Readme
react-hooks-firebase-auth
Library for easy handling of Firebase Authentication, complete with provider token related events
Sample Provider Use
const CompleteFirebaseAuthProvider = ({ children }): ReactElement => {
return (
<FirebaseAuthProvider
appName="app"
firebase={firebase}
loginComponent={<Login />}
loadingComponent={
<Loading
progress={30}
variant="warning"
message="Logging you in..."
/>
}
errorComponent={<p>Error</p>}
onNewLoginSuccess={onNewLoginSuccess}
onLogout={onLogout}
onOldLoginRetrieval={onOldLoginRetrieval}
>
{children}
</FirebaseAuthProvider>
);
};
And then for your main app file...
<CompleteFirebaseAuthProvider>
<App />
</CompleteFirebaseAuthProvider>
Sample Container use
import { useContainer } from 'unstated-next';
import { FirebaseAuthContainer } from 'react-hooks-firebase-auth';
const Component = () => {
const { user, token } = useContainer(FirebaseAuthContainer);
};
Sample Auth Enforcement
import { EnforceFirebaseAuth } from 'react-hooks-firebase-auth';
const Component = () => {
return (
<EnforceFirebaseAuth>
<AnotherComponent />
</EnforceFirebaseAuth>
);
};
OR
import { withFirebaseAuth } from 'react-hooks-firebase-auth';
const Component = () => {
return <AnotherComponent />;
};
export default withFirebaseAuth(Component);