Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.dev

useSignIn

Access the SignIn object inside of your components.

Overview

The useSignIn hook gives you access to the SignIn object inside your components.

You can use the methods of the SignIn object to create your own custom sign in flow, as an alternative to using Clerk's pre-built <SignIn/> component.

The SignIn object will also contain the state of the sign in attempt that is currently in progress, giving you the chance to examine all the details and act accordingly.

Usage

Getting access to the SignIn object from inside one of your components is easy. Note that the useSignIn hook can only be used inside a <ClerkProvider/> context.

The following example accesses the SignIn object to check the current sign in attempt's status.

Typescript

For better type support, we highly recommend updating to at least Typescript 4.6. Applications using Typescript will benefit significantly from Typescript's new Control Flow Analysis for Dependent Parameters when using our hooks.

A more involved example follows below. In this example, we show an approach to create your own custom form for signing in your users.

We recommend using the <SignIn/> component instead of building your own custom sign in form. It gives you a ready-made form and handles each step of the sign in flow.

Was this helpful?

Clerk © 2022