Embed Sign In / Up form in a page
#
Step 1: Disable default implementationThis will prevent SuperTokens from displaying the default login UI in the /auth
page.
- ReactJS
- Angular
- Vue
- Plain JavaScript
- React Native
Note
You can use the
You can refer to this example app as a reference for using the
supertokens-web-js
SDK which exposes several helper functions that query the APIs exposed by the SuperTokens backend SDK.You can refer to this example app as a reference for using the
supertokens-web-js
SDK.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
What type of UI are you using?
Prebuilt UICustom UI
What type of UI are you using?
Prebuilt UICustom UI
import SuperTokens from "supertokens-auth-react";
import ThirdParty from "supertokens-auth-react/recipe/thirdparty";
SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
ThirdParty.init({
signInAndUpFeature: {
disableDefaultUI: true,
// ...
},
// ...
}),
// ...
]
});
If you navigate to /auth
, you should not see the widget anymore.
#
Step 2: Render the component yourselfFor example if you would like to show the login form in our own component which renders custom UI around it, and is shown only of the user is logged in, then we can:
- ReactJS
- Angular
- Vue
- Plain JavaScript
- React Native
Note
You can use the
You can refer to this example app as a reference for using the
supertokens-web-js
SDK which exposes several helper functions that query the APIs exposed by the SuperTokens backend SDK.You can refer to this example app as a reference for using the
supertokens-web-js
SDK.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
What type of UI are you using?
Prebuilt UICustom UI
What type of UI are you using?
Prebuilt UICustom UI
import React from "react";
import { SignInAndUp } from 'supertokens-auth-react/recipe/thirdparty';
import Session from "supertokens-auth-react/recipe/session";
import Header from "./header";
import Footer from "./footer";
function MyLandingPage() {
let sessionContext = Session.useSessionContext();
if (sessionContext.loading) {
return null;
}
if (sessionContext.doesSessionExist) {
// We wrap this with <SessionAuth /> so that
// all claims are validated before showing the logged in UI.
// For example, if email verification is switched on, and
// the user's email is not verified, then <SessionAuth />
// will redirect to the email verification page.
return (
<Session.SessionAuth>
<Header />
You are logged in!
<Footer />
</Session.SessionAuth>
)
} else {
return (
<div>
<Header />
<SignInAndUp />
<Footer />
</div>
)
}
}
#
Step 3: Changing the website path for the login UIThe default path for this is component is /{websiteBasePath}/
.
If you are displaying this at some custom path, then you need add additional config on frontend:
- ReactJS
- Angular
- Vue
- Plain JavaScript
- React Native
Note
You can use the
You can refer to this example app as a reference for using the
supertokens-web-js
SDK which exposes several helper functions that query the APIs exposed by the SuperTokens backend SDK.You can refer to this example app as a reference for using the
supertokens-web-js
SDK.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
What type of UI are you using?
Prebuilt UICustom UI
What type of UI are you using?
Prebuilt UICustom UI
import SuperTokens from "supertokens-auth-react";
import ThirdParty from "supertokens-auth-react/recipe/thirdparty";
SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "...",
},
recipeList: [
ThirdParty.init({}),
],
// The user will be taken to the custom path when then need to login.
getRedirectionURL: async (context) => {
if (context.action === "TO_AUTH") {
return "/custom-login-path";
};
}
})