<SignIn />
component

The <SignIn />
component renders a UI to allow users to sign in or sign up by default. The functionality of the <SignIn />
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 <SignIn />
component by passing additional properties at the time of rendering.
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
fallback
- Type
ReactNode
- Description
An optional element to be rendered while the component is mounting.
- Name
fallbackRedirectUrl
- 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/
. 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 in. It's recommended to use the environment variable instead.
- Name
initialValues
- Type
SignInInitialValues
- Description
The values used to prefill the sign-in fields with.
- Name
path
- Type
string
- Description
The path where the component is mounted on when
routing
is set topath
. It is ignored in hash-based routing. For example:/sign-in
.
- Name
routing
- Type
'hash' | 'path'
- Description
The routing strategy for your pages. Defaults to
'path'
for frameworks that handle routing, such as Next.js and Remix. Defaults tohash
for all other SDK's, such as React.
- Name
signUpFallbackRedirectUrl
- Type
string
- Description
The fallback URL to redirect to after the user signs up, if there's no
redirect_url
in the path already. Used for the 'Don't have an account? Sign up' link that's rendered. Defaults to/
. It's recommended to use the environment variable instead.
- Name
signUpForceRedirectUrl
- Type
string
- Description
If provided, this URL will always used as the redirect destination after the user signs up. Used for the 'Don't have an account? Sign up' link that's rendered. It's recommended to use the environment variable instead.
- Name
signUpUrl
- Type
string
- Description
The full URL or path to the sign-up page. Used for the 'Don't have an account? Sign up' link that's rendered. It's recommended to use the environment variable instead.
- Name
transferable
- Type
boolean
- Description
Indicates whether or not sign in attempts are transferable to the sign up flow. Defaults to
true
. When set tofalse
, prevents opaque sign ups when a user attempts to sign in via OAuth with an email that doesn't exist. See OAuth account transfer flows for more information.
- Name
waitlistUrl
- Type
string
- Description
Full URL or path to the waitlist page. Use this property to provide the target of the 'Waitlist' link that's rendered. If
undefined
, will redirect to the Account Portal waitlist page. If you've passed thewaitlistUrl
prop to the<ClerkProvider>
component, it will infer from that, and you can omit this prop.
- Name
withSignUp
- Type
boolean
- Description
Opt into sign-in-or-up flow by setting this prop to
true
. Whentrue
, if a user does not exist, they will be prompted to sign up. If a user exists, they will be prompted to sign in. Defaults totrue
if theCLERK_SIGN_UP_URL
environment variable is set. Otherwise, defaults tofalse
.
Usage with frameworks
The following example includes basic implementation of the <SignIn />
component. You can use this as a starting point for your own implementation.
The following example demonstrates how you can use the <SignIn />
component on a public page.
If you would like to create a dedicated /sign-in
page in your Next.js application, there are a few requirements you must follow. See the dedicated guide for more information.
import { SignIn, useUser } from '@clerk/nextjs'
export default function Home() {
const { user } = useUser()
if (!user) return <SignIn />
return <div>Welcome!</div>
}
---
import { SignIn } from '@clerk/astro/components'
---
<SignIn />
If you would like to create a dedicated /sign-in
page in your Expo Web application, there are a few requirements you must follow. See the dedicated guide for more information.
import { SignIn } from '@clerk/clerk-expo/web'
export default function SignInPage() {
return <SignIn />
}
import { SignIn } from '@clerk/clerk-react'
const SignInPage = () => <SignIn />
export default SignInPage
If you would like to create a dedicated /sign-in
page in your React Router application, there are a few requirements you must follow. See the dedicated guide for more information.
import { SignIn } from '@clerk/react-router'
export default function SignInPage() {
return <SignIn />
}
If you would like to create a dedicated /sign-in
page in your Remix application, there are a few requirements you must follow. See the dedicated guide for more information.
import { SignIn } from '@clerk/remix'
export default function SignInPage() {
return <SignIn />
}
If you would like to create a dedicated /sign-in
page in your TanStack Start application, there are a few requirements you must follow. See the dedicated guide for more information.
import { SignIn } from '@clerk/tanstack-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/sign-in')({
component: SignIn,
})
function SignIn() {
return <SignIn />
}
<script setup lang="ts">
import { SignIn } from '@clerk/vue'
</script>
<template>
<SignIn />
</template>
Usage with JavaScript
The following methods available on an instance of the Clerk
class are used to render and control the <SignIn />
component:
The following examples assume that you have followed the quickstart in order to add Clerk to your JavaScript application.
mountSignIn()
Render the <SignIn />
component to an HTML <div>
element.
function mountSignIn(node: HTMLDivElement, props?: SignInProps): void
- Name
node
- Type
HTMLDivElement
- Description
The container
<div>
element used to render in the<SignIn />
component
- Name
props?
- Type
SignInProps
- Description
The properties to pass to the
<SignIn />
component
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-in"></div>
`
const signInDiv = document.getElementById('sign-in')
clerk.mountSignIn(signInDiv)
unmountSignIn()
Unmount and run cleanup on an existing <SignIn />
component instance.
function unmountSignIn(node: HTMLDivElement): void
- Name
node
- Type
HTMLDivElement
- Description
The container
<div>
element with a rendered<SignIn />
component instance
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-in"></div>
`
const signInDiv = document.getElementById('sign-in')
clerk.mountSignIn(signInDiv)
// ...
clerk.unmountSignIn(signInDiv)
openSignIn()
Opens the <SignIn />
component as an overlay at the root of your HTML body
element.
function openSignIn(props?: SignInProps): void
- Name
props?
- Type
SignInProps
- Description
The properties to pass to the
<SignIn />
component.
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.openSignIn()
closeSignIn()
Closes the sign in overlay.
function closeSignIn(): void
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.openSignIn()
// ...
clerk.closeSignIn()
Customization
To learn about how to customize Clerk components, see the customization documentation.
If Clerk's prebuilt components don't meet your specific needs or if you require more control over the logic, you can rebuild the existing Clerk flows using the Clerk API. For more information, see the custom flow guides.
Feedback
Last updated on