
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
@react-firebase/auth
Advanced tools
Easily integrate Firebase Authentication in your react(-native) app.
Easily integrate Firebase Authentication in your react(-native) app.
React Firebase Auth exports the following components :
yarn add @react-firebase/auth
# or
npm i @react-firebase/auth
Change PROJECT_NAME to your project name and grab your firebase config here : https://console.firebase.google.com/project/PROJECT_NAME/settings/general/
// Firebase Config
const config = {
apiKey: "API_KEY",
authDomain: "AUTH_DOMAIN",
projectId: "PROJECT_ID",
// OPTIONAL
databaseURL: "DATABASE_URL",
storageBucket: "STORAGE_BUCKET",
messagingSenderId: "MESSAGING_SENDER_ID"
};
Place an AuthProvider Component anywhere in your component tree as an ancestor to any of the other react-firebase-auth-provider components and pass to it your firebase config.
import firebase from "firebase/app";
import "firebase/auth";
import {
FirebaseAuthProvider,
IfFirebaseUnAuthed,
IfFirebaseAuthed,
FirebaseAuthConsumer,
IfFirebaseAuthedAnd
} from "react-firebase-auth-provider";
const config = {
apiKey: "API_KEY",
authDomain: "AUTH_DOMAIN",
projectId: "PROJECT_ID",
// OPTIONAL
databaseURL: "DATABASE_URL",
storageBucket: "STORAGE_BUCKET",
messagingSenderId: "MESSAGING_SENDER_ID"
};
const MyApp = () => {
return (
<FirebaseAuthProvider {...config} firebase={firebase}>
<div>
<button
onClick={() => {
const googleAuthProvider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(googleAuthProvider);
}}
>
Sign In with Google
</button>
<button
onClick={() => {
firebase.auth().signInAnonymously();
}}
>
Sign In Anonymously
</button>
<button
onClick={() => {
firebase.auth().signOut();
}}
>
Sign Out
</button>
<FirebaseAuthConsumer>
{({ isSignedIn, user, providerId }) => {
return (
<pre style={{ height: 300, overflow: "auto" }}>
{JSON.stringify({ isSignedIn, user, providerId }, null, 2)}
</pre>
);
}}
</FirebaseAuthConsumer>
<div>
<IfFirebaseAuthed>
{() => {
return <div>You are authenticated</div>;
}}
</IfFirebaseAuthed>
<IfFirebaseAuthedAnd
filter={({ providerId }) => providerId !== "anonymous"}
>
{({ providerId }) => {
return <div>You are authenticated with {providerId}</div>;
}}
</IfFirebaseAuthedAnd>
</div>
</div>
</FirebaseAuthProvider>
);
};
FAQs
Easily integrate Firebase Authentication in your react(or react-native) app.
The npm package @react-firebase/auth receives a total of 830 weekly downloads. As such, @react-firebase/auth popularity was classified as not popular.
We found that @react-firebase/auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.