SAWO React Component

React is a free and open-source front-end JavaScript library for building user interfaces or UI components. A Component is one of the core building blocks of React.

Let's get your React Component running with SAWO 🙌


Node [Version 12.x+ ] , Node Package Manager (NPM) [Version 6.x+]


1. The first step to getting started with SAWO API integration into your React web page is to install the sawo-react package as given below:
npm i sawo-react
2. After installation is done, you have to import the SawoLogin class from the installed sawo package to the top of the file:
import SawoLogin from 'sawo-react'
3. To use SAWO Login you would need an API key which can be obtained by creating a project in the sawo dashboard.
4. Once you create your project, you would need to set your project name and hostname. 4.1. For development in a local machine, the hostname should be set to 'localhost'.
If using ''localhost" as hostname is not working for you, try ""
4.2. For production, the hostname should be set to your domain.
If you are adding your domain do not add 'https://', ''http://', 'www' or even trailing backslash. Example: should be kept as
5. Copy the API key from the project and keep it safe and secure.
The best practice to store your API key is to store values in .env so that they are not exposed.
6. Initialize SAWO and render the form according to the following steps:
  • Define a callback function
function sawoLoginCallback(payload) {
  • Make a config object. The code given below should help in the same.
const sawoConfig = {
onSuccess: sawoLoginCallback, //required
//required must be one of: 'email', 'phone_number_sms', or 'both_email_phone'
identifierType: 'email',
apiKey: '', //required get it from sawo,
containerHeight: '300px', //required the login container height, default is 300px
Every added custom field should be accompanied by an 65px increase in the component height.
  • Add the react component to the main page where the Login Component has to render.
<SawoLogin config={sawoConfig}/>
7. Below code-block can be used as a reference after you have completed setting up your project:
import React, { useEffect } from 'react'
import SawoLogin from 'sawo-react'
const LoginPage = () => {
function sawoLoginCallback(payload) {
const sawoConfig = {
onSuccess: sawoLoginCallback //required,
//required must be one of: 'email', 'phone_number_sms', or 'both_email_phone'
identifierType: 'email'
apiKey: '' // required, get it from sawo,
containerHeight: '300px', // the login container height, default is 300px
return (
<SawoLogin config={sawoConfig}/>
export default LoginPage
8. Once the SAWO SDK is successfully set up, a login form will be rendered in the provided container as displayed in the picture below:
Congratulations !! The SAWO React Component is now ready to be used in your React application 🤘.

You can also check out SAWO's React Component Sample Code and Deployed App.

It's okay, we get it! You got Stuck!
Feel free to contact us on #ask-for-help on our Discord.