Skip to main content
Which UI do you use?
Custom UI
Pre built UI

2. Showing the Login UI

1) Create the pages/auth/[[...path]].tsx page #

  • Be sure to create the auth folder in the pages folder.
  • [[...path]].tsx will contain the component for showing SuperTokens UI

2) Create the Auth component: #

import React, { useEffect } from 'react'
import dynamic from 'next/dynamic'
import { ThirdPartyPasswordlessPreBuiltUI } from "supertokens-auth-react/recipe/thirdpartypasswordless/prebuiltui";
import { redirectToAuth } from 'supertokens-auth-react'
import { canHandleRoute, getRoutingComponent } from 'supertokens-auth-react/ui'

const SuperTokensComponentNoSSR = dynamic<{}>(
new Promise((res) => res(() => getRoutingComponent([ThirdPartyPasswordlessPreBuiltUI]))),
{ ssr: false }

export default function Auth() {

// if the user visits a page that is not handled by us (like /auth/random), then we redirect them back to the auth page.
useEffect(() => {
if (canHandleRoute([ThirdPartyPasswordlessPreBuiltUI]) === false) {
}, [])

return (
<SuperTokensComponentNoSSR />

3) Visit /auth page on your website #

If you see a login UI, then you have successfully completed this step! If not, please feel free to ask questions on Discord

Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI