Docs

<SignUp /> component

The <SignUp /> component renders a UI for signing up users.

The <SignUp /> component renders a UI for signing up users. The functionality of the <SignUp /> component is controlled by the instance settings you specify in the Clerk Dashboard, such as sign-in and sign-up options and social connections. You can further customize your <SignUp /> component by passing additional properties at the time of rendering.

Note

The <SignUp/> and <SignIn/> components cannot render when a user is already signed in, unless the application allows multiple sessions. If a user is already signed in and the application only allows a single session, Clerk will redirect the user to the Home URL instead.

Properties

All props are optional.

  • Name
    appearance
    Type
    Appearance | undefined
    Description

    Optional object to style your components. Will only affect Clerk components and not Account Portal pages.

  • Name
    routing
    Type
    'hash' | 'path' | 'virtual'
    Description

    The routing strategy for your pages.
    Defaults to 'path' in Next.js and Remix applications. Defaults to hash for all other SDK's.

  • Name
    path
    Type
    string
    Description

    The path where the component is mounted on when routing is set to path. It is ignored in hash- and virtual-based routing.
    For example: /sign-up.

  • Name
    signInUrl
    Type
    string
    Description

    Full URL or path to the sign in page. Use this property to provide the target of the 'Sign In' link that's rendered. It's recommended to use the environment variable instead.

  • Name
    forceRedirectUrl?
    Type
    string
    Description

    If provided, this URL will always be redirected to after the user signs up. Takes priority over deprecated props such as afterSignUpUrl and redirectUrl. It's recommended to use the environment variable instead.

  • Name
    fallbackRedirectUrl?
    Type
    string
    Description

    The fallback URL to redirect to after the user signs up, if there's no redirect_url in the path already. Defaults to /. Takes priority over deprecated props such as afterSignUpUrl and redirectUrl. It's recommended to use the environment variable instead.

  • Name
    signInForceRedirectUrl?
    Type
    string
    Description

    If provided, this URL will always be redirected to after the user signs in. Takes priority over deprecated props such as afterSignUpUrl and redirectUrl. It's recommended to use the environment variable instead.

  • Name
    signInFallbackRedirectUrl?
    Type
    string
    Description

    The fallback URL to redirect to after the user signs in, if there's no redirect_url in the path already. Defaults to /. Takes priority over deprecated props such as afterSignUpUrl and redirectUrl. It's recommended to use the environment variable instead.

  • Name
    initialValues
    Type
    SignUpInitialValues
    Description

    The values used to prefill the sign-up fields with.

  • Name
    unsafeMetadata
    Type
    SignUpUnsafeMetadata
    Description

    Metadata that can be read and set from the frontend and the backend. Once the sign-up is complete, the value of this field will be automatically copied to the created user's unsafe metadata (User.unsafeMetadata). One common use case is to collect custom information about the user during the sign-up process and store it in this property. Read more about unsafe metadata.

Usage with frameworks

The following example includes basic implementation of the <SignUp /> component. You can use this as a starting point for your own implementation.

The following example demonstrates how you can use the <SignUp /> component on a public page.

If you would like to create a dedicated /sign-up page in your Next.js application, see the dedicated guide.

app/page.tsx
import { SignUp, useUser } from '@clerk/nextjs'

export default function Home() {
  const { user } = useUser()

  if (!user) {
    return <SignUp />
  }

  return <div>Welcome!</div>
}
/src/sign-up/[[...index]].tsx
import { SignUp } from '@clerk/clerk-react'

const SignUpPage = () => <SignUp path="/sign-up" />

export default SignUpPage
app/routes/sign-up/$.tsx
import { SignUp } from '@clerk/remix'

export default function SignUpPage() {
  return (
    <div style={{ border: '2px solid blue', padding: '2rem' }}>
      <h1>Sign Up route</h1>
      <SignUp />
    </div>
  )
}
pages/sign-up.astro
---
import { SignUp } from '@clerk/astro/components'
---

<SignUp path="/sign-up" />

Usage with JavaScript

The following methods available on an instance of the Clerk class are used to render and control the <SignUp /> component:

The following examples assume that you have followed the quickstart in order to add Clerk to your JavaScript application.

mountSignUp()

Render the <SignUp /> component to an HTML <div> element.

function mountSignUp(node: HTMLDivElement, props?: SignUpProps): void
  • Name
    node
    Type
    HTMLDivElement
    Description

    The <div> element used to render in the <SignUp /> component

  • Name
    props?
    Type
    SignUpProps
    Description

    The properties to pass to the <SignUp /> component.

main.ts
import { Clerk } from '@clerk/clerk-js'

// Initialize Clerk with your Clerk Publishable Key
const clerkPubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY

const clerk = new Clerk(clerkPubKey)
await clerk.load()

document.getElementById('app').innerHTML = `
  <div id="sign-up"></div>
`

const signUpDiv = document.getElementById('sign-up')

clerk.mountSignUp(signUpDiv)

unmountSignUp()

Unmount and run cleanup on an existing <SignUp /> component instance.

function unmountSignUp(node: HTMLDivElement): void
  • Name
    node
    Type
    HTMLDivElement
    Description

    The container <div> element with a rendered <SignUp /> component instance

main.ts
import { Clerk } from '@clerk/clerk-js'

// Initialize Clerk with your Clerk Publishable Key
const clerkPubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY

const clerk = new Clerk(clerkPubKey)
await clerk.load()

document.getElementById('app').innerHTML = `
  <div id="sign-up"></div>
`

const signUpDiv = document.getElementById('sign-up')

clerk.mountSignUp(signUpDiv)

// ...

clerk.unmountSignUp(signUpDiv)

openSignUp()

Opens the <SignUp /> component as an overlay at the root of your HTML body element.

function openSignUp(props?: SignUpProps): void
  • Name
    props?
    Type
    SignUpProps
    Description

    The properties to pass to the <SignUp /> component

main.js
import { Clerk } from '@clerk/clerk-js'

// Initialize Clerk with your Clerk Publishable Key
const clerkPubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY

const clerk = new Clerk(clerkPubKey)
await clerk.load()

clerk.openSignUp()

closeSignUp()

Closes the sign up overlay.

function closeSignUp(): void
main.js
import { Clerk } from '@clerk/clerk-js'

// Initialize Clerk with your Clerk Publishable Key
const clerkPubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY

const clerk = new Clerk(clerkPubKey)
await clerk.load()

clerk.openSignUp()

// ...

clerk.closeSignUp()

Customization

To learn about how to customize Clerk components, see the customization documentation.

Feedback

What did you think of this content?

Last updated on