Redirect To Auth Screen
redirectToAuth
function#
Using the - ReactJS
- Plain JavaScript
- React Native
Note
To use SuperTokens with plain javascript you need to use the
To add login functionality, you need to build your own UI and call the APIs exposed by the backend SDKs. You can find the API spec here
You can refer to this blog post to know how this is done, the example uses social login but the same setup applies to other recipes as well.
supertokens-website
SDK. The SDK provides session management features.To add login functionality, you need to build your own UI and call the APIs exposed by the backend SDKs. You can find the API spec here
You can refer to this blog post to know how this is done, the example uses social login but the same setup applies to other recipes as well.
Note
To use SuperTokens with React Native you need to use the
To add login functionality, you need to build your own UI and call the APIs exposed by the backend SDKs. You can find the API spec here
supertokens-react-native
SDK. The SDK provides session management features.To add login functionality, you need to build your own UI and call the APIs exposed by the backend SDKs. You can find the API spec here
Use the redirectToAuth({show?: "signin" | "signup", redirectBack?: boolean}?)
function to redirect the user to the full page auth screen provided by SuperTokens.
import React from "react";import { redirectToAuth } from "supertokens-auth-react/recipe/passwordless";
function NavBar () { async function onLogin () { redirectToAuth(); } return ( <ul> <li>Home</li> <li onClick={onLogin}>Login</li>
</ul> )}
- Call
redirectToAuth({show: "signin"})
to take them to the sign in screen - Call
redirectToAuth({show: "signup"})
to take them to the sign up screen - If you want the user to be redirected to the current page post sign in, use
redirectToAuth({redirectBack: true})
#
Redirecting manuallyAlternatively, you can also redirect the user manually by setting window.location.href
or using an SPA router like react-router-dom
.
To show the sign in page on redirect, you want to add the query param ?show=signin
to the URL. To show the sign up page on redirect, you want to add ?show=signup
instead.
To make the user navigate back to where their current page, you should add the query param ?redirectToPath=/somepath