> For the complete documentation index, see [llms.txt](https://docs.chord.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chord.co/chord-oms/shopify/developer-tools/gatsby/sdk-reference/useauth.md).

# useAuth

The `useAuth` hook returns a series of methods that enable authentication with a Shopify customer account.

{% code title="useAuth" %}

```javascript
import { useAuth } from '@chordcommerce/gatsby-theme-performance'

const {
  isLoggedIn,
  status,
  getToken,
  login,
  logout,
  recover,
  register,
  resetPassword
} = useAuth()
```

{% endcode %}

### isLoggedIn

Boolean indicating whether a user is currently logged in.

### status

String indicating the status of authentication in Redux. This string can be used to determine if the authentication status has been verified yet, which happens asynchronously after page load.

**Example:**

{% code title="status" %}

```javascript
import { useAuth, AuthStatus } from '@chordcommerce/gatsby-theme-performance'

const { status } = useAuth()

if (status === AuthStatus.Failed) {
  // the authentication session has been checked and there is no current valid session
}
```

{% endcode %}

### getToken()

Retrieves the current Shopify customer access token.

**Example:**

{% code title="getToken" %}

```javascript
const token = await getToken()
```

{% endcode %}

### login()

Submits the email address and password for a Shopify customer and initiates an authentication session. This method creates a Shopify customer access token.

**Example:**

{% code title="login" %}

```javascript
await login({ email: 'test@test.com', password: 'testtest' })
```

{% endcode %}

### logout()

Clears the authentication session. This method destroys the current Shopify customer access token.

**Example:**

{% code title="logout" %}

```javascript
await logout()
```

{% endcode %}

### recover()

Sends a Shopify reset password email to the customer.

**Example:**

{% code title="recover" %}

```javascript
await recover('test@test.com')
```

{% endcode %}

### register()

Creates a new Shopify customer and initiates an authentication session. This method creates a Shopify customer access token.

**Example:**

{% code title="register" %}

```javascript
await register({ email: 'test@test.com', password: 'testtest' })
```

{% endcode %}

### resetPassword()

Resets a Shopify customer’s password with an id and token from a Shopify reset password email.

**Example:**

{% code title="resetPassword" %}

```javascript
await resetPassword({
  id: 'id',
  password: 'testtests', // the new password
  token: '123'
})
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.chord.co/chord-oms/shopify/developer-tools/gatsby/sdk-reference/useauth.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
