Quickstart Expo

In this guide we are going to implement the Faable Auth authentication service in React Native. The Identity Provider enables us to log in using Google, Facebook/Meta, Github, Shopify, Slack, among others, with a single configuration.

⚠️ Before starting:

  • Make sure you have the simulator installed according to the platform you are developing on, ios or Android.

  • Use your favorite code editor, in this case we will use VSCode.

🚀 Start

Open a new terminal to create a new project.

Complete the installation questions.

  1. Choose “Blank (TypeScript)”

  2. Name your app

  3. Wait for npm to install packages

Once the installation is complete, we run the project to check that everything is working correctly.

We will end up with this folder structure.

🧩 Login Button

We create a new file where we put the component, we call it LoginButton.tsx here's the code for it.

Modify the App.tsx file to add our <LoginButton/> component for the user to log in.

⚙️ Setup credentials

Create an auth folder and inside it create a faableauth.ts file and write all the necessary configuration.

Install Faable Auth required packages.

Start writing code inside faableauth.ts file as required by expo to properly configure user session handling with oauth2 protocol.

⚠️ WARNING: importing the react-native-url-polyfill/auto library is required for @faable/auth-js to work properly.

create an instance of the client that will be shared across the entire application and place the configuration credentials for Faable Auth.

✅ Use the credentials you'll find on the Faable Dashboard. Faable Auth is in beta so you'll need to request access by joining our Discord channel.

⚠️ IMPORTANT: You must define which social connection you are going to use to log in. You will find the connection IDs in the dashboard. The connection IDs have this format connection_xxxxxxxxxxxxxxxxxxxxxx

We define a global context for the entire application in the main project file App.tsx. Configure the context by passing as a prop the instance of faableauth that we have previously configured.

👤 User Profile

Return to the LoginButton.tsx file to place the needed logic that allows us to display the user's information when the user has completed the login flow. To do this, we will use the useSession() hook provided with our helper library @faable/auth-helpers-react that allows us to access the session and user data.

Links:

Here's the code repository with al, so you can clone it.

Last updated