React Native Setup
In this guide, you'll learn how to create a React Native app and initialize it with the Okto SDK, including setting up authentication using Google OAuth and the Okto Provider.
You can create an Okto-powered React Native application in three different ways. Choose the approach that best suits your needs:
- Using the React Native Community CLI to setup with manual configuration
- Streamlined Okto React Native setup
This approach uses React Native Community CLI to generate a new project and you can manually configures the Okto SDK. This gives you the most control over your setup and is great if you need to integrate Okto into an existing application.
Initialize React Native App
This creates a new React Native project in the OktoApp directory with all the necessary code.
Now we will install some required dependencies to integrate Google Login and Okto SDK.
Setup Google Console
- Go to the Google Cloud Console.
- Follow our Google Authentication Setup Guide to create a new project and obtain the necessary credentials.
Required Client IDs
Depending on your target platforms, you'll need:
- Android devices: Web Client ID and Android Client ID
- iOS devices: iOS Client ID
- Both platforms: Web Client ID, Android Client ID, and iOS Client ID
Initialize Okto SDK
To get started with authentication, we'll initialize the OktoProvider provider in the index.js
file.
View here
iOS Setup
In Xcode, open Info
tab as below:
Under the URL Types section, click
+
button. In the URL Schemes
field, enter your reversed iOS client ID
Initialize Google OAuth
Create new directory called src/components
with a file called GoogleSignInButton.tsx
in your root folder.
Now, we'll start with our Google OAuth setup.
Note
In case of android app, you don’t have to specify your OAUTH_ANDROID_CLIENT_ID
, only OAUTH_WEB_CLIENT_ID
is sufficient.
Create Necessary Files
Create another file called src/components/GetButton.tsx
.
Update src/App.tsx
If you haven't already, create a src/App.tsx
, this would be our main entry-point into the application.
Android Setup (Optional)
If in any case, your Android app fails to build, you can try fixing this using the steps given below.
Update android/build.gradle
file.
Congratulations!
🎉 Congratulations! You now have a basic app powered by Okto. You can focus on your business logic and UI/UX now. You can checkout how to use other features in the Template Repo.
For more details, refer to the Template Repo and the Okto SDK Cheatsheet for commonly used methods and configurations.