You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following example demonstrates how to use the `useAuth()` hook to access the current auth state, like whether the user is signed in or not. It also includes a basic example for using the `getToken()` method to retrieve a session token for fetching data from an external resource.
The following example uses the `useSignIn()` hook to access the [`SignIn`](/docs/reference/javascript/sign-in) 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.
14
+
15
+
<Ifsdk="react">
16
+
```tsx {{ filename: 'src/pages/SignInPage.tsx' }}
17
+
import { useSignIn } from'@clerk/clerk-react'
18
+
19
+
exportdefaultfunction SignInPage() {
20
+
const { isLoaded, signIn } =useSignIn()
21
+
22
+
if (!isLoaded) {
23
+
// Handle loading state
24
+
returnnull
25
+
}
26
+
27
+
return <div>The current sign-in attempt status is {signIn?.status}.</div>
28
+
}
29
+
```
30
+
</If>
31
+
32
+
<Ifsdk="nextjs">
33
+
```tsx {{ filename: 'app/sign-in/page.tsx' }}
34
+
'use client';
35
+
36
+
import { useSignIn } from'@clerk/nextjs';
37
+
38
+
exportdefaultfunction SignInPage() {
39
+
const { isLoaded, signIn } =useSignIn();
40
+
41
+
if (!isLoaded) {
42
+
// Handle loading state
43
+
returnnull;
44
+
}
45
+
46
+
return <div>The current sign-in attempt status is {signIn?.status}.</div>;
47
+
}
48
+
```
49
+
</If>
50
+
51
+
### Create a custom sign-in flow with `useSignIn()`
52
+
53
+
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](/docs/guides/development/custom-flows/overview).
0 commit comments