The useSignIn() hook provides access to the SignInJavaScript Icon object, which allows you to check the current state of a sign-in attempt and manage the sign-in flow. You can use this to create a custom sign-in flow.
The following example uses the useSignIn() hook to access the SignInJavaScript Icon object, which contains the current sign-in attempt status and methods to create a new sign-in attempt. The isLoaded property is used to handle the loading state.
app/routes/index.tsx
import { useSignIn } from'@clerk/tanstack-react-start'import { createFileRoute } from'@tanstack/react-router'exportconstRoute=createFileRoute('/')({ component: SignInPage,})exportdefaultfunctionSignInPage() {const { isLoaded,signIn } =useSignIn()// Handle loading stateif (!isLoaded) return <div>Loading...</div>return <div>The current sign-in attempt status is {signIn?.status}.</div>}
The useSignIn() hook can also be used to build fully custom sign-in flows, if Clerk's prebuilt components don't meet your specific needs or if you require more control over the authentication flow. Different sign-in flows include email and password, email and phone codes, email links, and multifactor (MFA). To learn more about using the useSignIn() hook to create custom flows, see the custom flow guides.