> For the complete documentation index, see [llms.txt](https://docs.billingjs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.billingjs.com/hooks/useauth.md).

# useAuth

### `useAuth`

A custom React hook that manages user authentication and authorization.

#### Usage

<pre class="language-javascript"><code class="lang-javascript"><a data-footnote-ref href="#user-content-fn-1">import { useAuth } from '@billing-js/react-billing-js'</a>

function MyComponent(props) {
  const { signIn, signOut, loading, user } = useAuth()

  // use the signIn, signOut, loading, and user values to render the component
}
</code></pre>

#### Arguments

This hook takes no arguments.

#### Returns

* `user` (`User | null`): An object representing the authenticated user, or `null` if no user is authenticated.
* `loading` (`boolean`): A boolean indicating whether the hook is currently in the process of fetching data.
* `signIn` (`({ hmac, email }: { hmac: any; email: any }) => Promise<void>`): A function that accepts an object with two properties, `hmac` and `email`, and returns a promise that resolves when the user is signed in.
* `signOut` (`() => Promise<void>`): A function that returns a promise that resolves when the user is signed out.

[^1]:
