Learn how to use the Nile Auth Sign In component
auth.session
table.
@tanstack/react-query
and react-hook-form
are used to do much of the heavy lifting in the component. The component is styled via tailwind.
<Email />
and <Password />
fields, along with the useSignIn()
hook to sign a user in, if they exist. In most cases, you want to supply a callbackUrl
, which is where the user will be redirected upon successful sign in. Error handling works the same as it does in <SignUpForm />
callbackUrl
useSignIn
hook provides a way to authenticate users using credential-based sign-in within a React application. It utilizes React Query’s useMutation
to handle authentication requests and supports optional lifecycle callbacks for customization.
useSignIn(params?: Props): (data: LoginInfo) => void
Name | Type | Description |
---|---|---|
params | Props (optional) | Configuration options |
LoginInfo
containing user credentials to initiate the sign-in process.
Name | Type | Description |
---|---|---|
callbackUrl | string (recommended) | The URL to redirect to upon successful login. |
beforeMutate | (data: any) => any (optional) | Optional function executed before the mutation occurs, allowing modification of request data. |
onSuccess | (data: LoginSuccess) => void (optional) | Callback function triggered on a successful login. |
onError | (error: Error, data: any) => void (optional) | Callback function triggered if the login fails. |
client | QueryClient (optional) | React Query client instance. |
beforeMutate
to modify request payloads before submission.callbackUrl
parameter determines the redirection URL post-login.className
and buttonText
props,
or using Tailwind CSS theme variables. You can find more details and full examples in the customization doc.
In addition, the hooks documented for each component can be used if you’d like to use Nile Auth with your own components.
If needed, you can peek at the source code of the component and use it as a template to create your own component for maximum customization.