Quick Example
Let's do this thing.
Pre-requisites
Make sure you've already completed the setup guide.
Two ways to get started
🏄🏽♂️
withPhoneAuth
higher-order component API (simplest)🌊
<AuthFlow />
component-based API (more customized)
Which should you use? It's a matter of preference. If you aren't sure, just stick to #1.
#2 probably fits in better if you're using React Navigation.
withPhoneAuth
example
withPhoneAuth
exampleThis is the easiest way to add phone auth to your app:
Replace the publicProjectId field with yours.
How do I find my public project ID?
There are many customizations you can make with thewithPhoneAuth
HOC, including a splash screen, loading screen, custom screen props, and more. See the docs for it here.
Under the hood, withPhoneAuth
is actually implementing the <AuthFlow />
component. Let's see how that looks in the next example.
<AuthFlow />
Example
<AuthFlow />
ExampleIf you like more customization, and a component-based API, this option is your best bet.
Replace the publicProjectId field with your actual Doorman project ID.
How do I find my project ID?
What's going on above?
First, we wrap our entire app with the
DoormanProvider
. This allows our entire app to have access to the same Doorman instance.Second, we use Doorman's super-convenient
AuthGate
component.Thanks to AuthGate, there's no longer a need to set up listeners like
firebase.onAuthStateChanged
or anything like that.You could also create your own
AuthGate
component usinguseAuthGate
.
Finally, We render Doorman's
<AuthFlow />
if the user hasn't authenticated yet. This component is all you need for the phone auth screens.
Find Doorman Public Project ID
Sign in to Doorman
Go to the projects screen
Copy your project public ID under the name of your project
Important You must complete the Setup Guide before you can use your Public Project ID.
Find Firebase project config
Your Firebase web app config object looks like this:
You can find it in your Firebase console.
Last updated