React Setup
In this guide, you'll learn how to create a React 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 application in three different ways. Choose the approach that best suits your needs:
- Traditional Create React App setup with manual configuration:
Best for developers who need full control and customization over their project. - Streamlined Okto React setup:
The easiest way to get started with a pre-configured setup. - Streamlined Okto Next.js-based setup:
Ideal for Next.js developers looking to leverage Okto with minimal configuration.
This approach uses Create React App and 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 React application.
Create React App
Run the following commands in your terminal to create a new React app:
This sets up a new React project in the folder my-okto-app
with all the default settings.
Install the Okto SDK
Run the following commands to add Okto's SDK and Google OAuth to your project. Choose the command that matches your package manager:
This installs the SDK and adds it as a dependency in your project.
Initialize Okto SDK
To get started with authentication, we'll initialize the Google OAuth provider in the index.js
file.
View here
Sample Login Page
Now, we will create a sample LoginPage.js
file to test out our functionalities:
View here
Congratulations!
🎉 Congratulations! You now have a basic dApp 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.