Custom sign-up flow
Build a registration UI tailored to an application’s product and validation requirements.
Clerk · Hook
useSignUp() gives a React component access to Clerk’s current SignUpFuture resource. Use its returned state and resource to inspect and manage a sign-up attempt, including custom flows.
Call useSignUp() in a React component to obtain the current SignUpFuture resource, its loading state, and errors from the latest fetch. The returned signUp object exposes the current attempt and methods for managing a custom sign-up flow.
const { errors, fetchStatus, signUp } = useSignUp(){ errors: SignUpErrors; fetchStatus: "idle" | "fetching"; signUp: SignUpFutureResource }
import { useSignUp } from '@clerk/react'
export function SignUpStatus() {
const { signUp, fetchStatus, errors } = useSignUp()
return (
<p>
{fetchStatus === 'fetching'
? 'Loading sign-up…'
: errors.length
? 'Sign-up error'
: signUp.status}
</p>
)
}Reads the current sign-up resource, fetch state, and errors from Clerk’s hook.
Build a registration UI tailored to an application’s product and validation requirements.
Show progress while Clerk retrieves or updates the current sign-up resource.
Present feedback when the latest sign-up resource fetch fails.
useSignUp() returns access to the SignUpFuture object for the current sign-up attempt. Its return value includes signUp, fetchStatus, and errors.
Follow-up: Why should signUp be included in React dependency arrays? Its identity is not stable and may change as the sign-up flow progresses.
fetchStatus reports whether the underlying SignUpFuture is idle or fetching. errors contains problems from the last fetch of that resource.
Follow-up: How would you render a loading state? Check whether fetchStatus equals "fetching" before displaying the loaded sign-up state.
The hook is intended for checking the current sign-up attempt and managing the sign-up flow, including custom flows. The signUp resource is the object used for those operations.
Follow-up: When is a custom flow appropriate? Use it when the prebuilt sign-up components do not provide the required control or behavior.
SignUpFutureSignUpFutureResourceSignUpErrorsuseEffectuseCallbackuseMemo