@authorizerdev/authorizer-react exports the few components that you can use in your react application. This will help you build authentication and authorization faster for your application.
AuthorizerProviderAuthorizerAuthorizerSignupAuthorizerBasicAuthLoginAuthorizerMagicLinkLoginAuthorizerSocialLoginAuthorizerForgotPasswordAuthorizerResetPasswordAuthorizerVerifyOtp
AuthorizerProvider is the container component that wraps all the Authorizer components. It binds the backend configuration in the app and renders various views accordingly.
config: Object to configure theauthorizerbackend URL and redirect URL. It accepts JSON object with following keys
| Key | Type | Description | Required |
|---|---|---|---|
authorizerURL |
string |
Authorizer backend URL | true |
redirectURL |
string |
Frontend application URL or the page where you want to redirect user post login. Default value is window.location.origin |
true |
onStateChangeCallback |
function |
[optional] Async callback that is called whenever context state information changes. | false |
import { AuthorizerProvider } from '@authorizerdev/authorizer-react'
const App = () => {
return (
<AuthorizerProvider
config={{
authorizerURL: 'http://localhost:8080',
redirectURL: window.location.origin,
}}
onStateChangeCallback={async (newState) => {}}
>
// REST of the components goes here.
</AuthorizerProvider>
)
}A core component that includes:
- social logins
- signup view
- login view
- forgot password view
Pre configured component that shows various login/signup options based on the backend configurations. Make sure it is used as Child of AuthorizerProvider.
It has following optional props as callback events that are triggered via various user events.
onLogin={(loginResponse)=>{}}: event called when login form is submitted successfully.onMagicLinkLogin={(magicLinkResponse)=>{}}: event called when magic link login form is submitted successfully.onSignup={(signupResponse)=>{}}: event called when signup form is submitted successfully.onForgotPassword={(forgotPasswordResponse)={}}: called when forgot password form is submitted successfully.
import { Authorizer } from '@authorizerdev/authorizer-react'
const LoginPage = () => {
return (
<>
<h1 style={{ textAlign: 'center' }}>Login / Signup</h1>
<br />
<Authorizer
onLogin={(loginResponse) => {}}
onMagicLinkLogin={(magicLinkResponse) => {}}
onSignup={(signupResponse) => {}}
onForgotPassword={(forgotPasswordResponse = {})}
/>
</>
)
}A component to render basic authentication singup form. Make sure it is used as Child of AuthorizerProvider.
onSignup={(response)=>{}}: event called when signup form is submitted successfully.
import { AuthorizerSignup } from '@authorizerdev/authorizer-react'
const SignupPage = () => {
return (
<>
<h1 style={{ textAlign: 'center' }}>Signup</h1>
<br />
<AuthorizerSignup onSignup={(response) => {}} />
</>
)
}A component to render basic authentication login form. Make sure this is used as Child of AuthorizerProvider.
onLogin={(response)=>{}}: event called when login form is submitted successfully.
import { AuthorizerBasicAuthLogin } from '@authorizerdev/authorizer-react'
const LoginPage = () => {
return (
<>
<h1 style={{ textAlign: 'center' }}>Login</h1>
<br />
<AuthorizerBasicAuthLogin onLogin={(response) => {}} />
</>
)
}A component to render magic link login form. Make sure this is used as Child of AuthorizerProvider.
onMagicLinkLogin={(response)=>{}}: event called when magic link login form is submitted successfully.
import { AuthorizerMagicLinkLogin } from '@authorizerdev/authorizer-react'
const LoginPage = () => {
return (
<>
<h1 style={{ textAlign: 'center' }}>Login</h1>
<br />
<AuthorizerMagicLinkLogin onMagicLinkLogin={(response) => {}} />
</>
)
}A component to render list of social media login buttons based on backend configurations. Make sure this is used as Child of AuthorizerProvider.
onForgotPassword={(response)=>{}}: event called when forgot password form is submitted successfully.
import { AuthorizerSocialLogin } from '@authorizerdev/authorizer-react'
const LoginPage = () => {
return (
<>
<h1 style={{ textAlign: 'center' }}>Login / Signup</h1>
<br />
<AuthorizerSocialLogin />
</>
)
}A component to render forgot password form. Make sure this is used as Child of AuthorizerProvider.
No props exposed for this components
import { AuthorizerForgotPassword } from '@authorizerdev/authorizer-react'
const ForgotPasswordPage = () => {
return (
<>
<h1 style={{ textAlign: 'center' }}>Forgot Password?</h1>
<br />
<AuthorizerForgotPassword onForgotPassword={(response) => {}} />
</>
)
}A component that can be used to reset the password. This component can be used in the page, which is configured with the backend as RESET_PASSWORD_URL, check environment variables for more details. This component validates the token in the URL sent via email to the user and helps resetting the password.
It has following optional prop as callback event that is triggered on form submit.
onReset={(response) => {}}: Called when reset form is submitted
import { AuthorizerResetPassword } from '@authorizerdev/authorizer-react'
const ResetPassword = () => {
return (
<>
<h1 style={{ textAlign: 'center' }}>Reset Password</h1>
<br />
<AuthorizerResetPassword onReset={(response) => {}} />
</>
)
}A component to render the OTP verification form. Make sure it is used as Child of AuthorizerProvider.
email="foo@bar.com": user email address on which the OTP was sent.
It also has following optional prop as callback event that is triggered on form submit.
onLogin={(response)=>{}}: event called when verify OTP form is submitted successfully.
import { AuthorizerVerifyOtp } from '@authorizerdev/authorizer-react'
const VerifyOtp = () => {
return (
<>
<h1 style={{ textAlign: 'center' }}>Verify OTP</h1>
<br />
<AuthorizerVerifyOtp email="foo@bar.com" onLogin={(response) => {}} />
</>
)
}