React Native — Full authentication flow with Spotify — Chapter 1: Building our React Native app

This article is a part of a larger series in which I want to show you how I set up Authentication with Spotify in my React Native application.
Content
I will publish this series through different chapters:
- Introduction
- Chapter 1: Building our React Native app
- Chapter 2: Backend Proxy based on Firebase Functions and Express
Coming up next:
- Chapter 3: Bringing Backend and Frontend together
- Chapter 4: React Native Navigation based on authentication state
- Chapter 5: Keeping your user base in Firestore
What will we do in Chapter 1?
- Register a Spotify Application
- Initialize our React Native application
- Use an auth library to prepare our React Native app for authentication
- Create one view with a login button that will prompt the Spotify login screen
- Run it on Android
Install Node.js / NPM
You will need Node.js to be able to continue with the following steps.
Prepare your Android Development environment
Follow the steps of the official documentation. Scroll down to “Android development environment” and install Android Studio.
Through this series, we will test our app on Android.
Register a Spotify Application
Create an account on https://developer.spotify.com/
In your Dashboard, you will find a button to create a new client id.

Complete the wizard:

After completing all the steps you will see this screen:

On this page, you can edit your Spotify App settings. On the top left side, your Client ID and Client Secret are displayed. When pressing the “edit settings” button, the possibility to add Redirect URIs will pop out.
In further steps, you will need your Client ID and Client Secret. For the moment, just remember that you can find them here.
Initializing our React Native Application
Skip this part if you already have a React Native project
So let’s start by initializing our React Native app Open command prompt and cd your way to your project directory.
Initialize a project with:
npx react-native init AwesomeProjectNote: Since NPM version 5.2.0 npx is prepackaged in npm. With npx you can use any node package directly from the npm registry without installing it. In the past, we would install the package globally (npm install react-native -g) and then use it directly from our computer. This isn’t necessary anymore, which means you will always be using the last version available on npm.
Open the project in your favorite IDE. I will be working in Visual Studio. https://code.visualstudio.com/
Edit your folder structure:

Handling authentication
Handling the standard oAuth flow is something that happens in a lot of applications. So, somewhere, someone has already written this code.
Thank god for the internet: react-native-app-auth
I have been using this library for my React Native authentication. I’m sure there are a lot of good alternatives, so take your pick!
Navigate to our new project:
cd AwesomeProjectInstall the auth library which we will be using
npm install react-native-app-auth --save












