---
title: useAuth
slug: oms/S8mm-useauth
docTags: 
createdAt: 2022-11-09T15:26:04.000Z
---

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

::::CodeDrawer{title="useAuth" isResponseExpanded="false" autoGeneratedAnchorSlug="useauth" legacyHash="FRCFjL_SSyQv1cYwyhTPq"}
:::CodeblockTabsExamples
```javascript
import { useAuth } from '@chordcommerce/gatsby-theme-performance'

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

:::CodeblockTabsResponses
```javascript
```
:::
::::

### 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:**

::::CodeDrawer{title="status" isResponseExpanded="false" autoGeneratedAnchorSlug="status-1" legacyHash="sc5wWnLtfU-NYKS4AvwHi"}
:::CodeblockTabsExamples
```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
}
```
:::

:::CodeblockTabsResponses
```javascript
```
:::
::::

### getToken()

Retrieves the current Shopify customer access token.

**Example:**

::::CodeDrawer{title="getToken" isResponseExpanded="false" autoGeneratedAnchorSlug="gettoken-1" legacyHash="9_M2w6q6u6QpY53MRegqA"}
:::CodeblockTabsExamples
```javascript
const token = await getToken()
```
:::

:::CodeblockTabsResponses
```javascript
```
:::
::::

### 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:**

::::CodeDrawer{title="login" isResponseExpanded="false" autoGeneratedAnchorSlug="login-1" legacyHash="dTdXfF24w86oOblpC8Q5u"}
:::CodeblockTabsExamples
```javascript
await login({ email: 'test@test.com', password: 'testtest' })
```
:::

:::CodeblockTabsResponses
```javascript
```
:::
::::

### logout()

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

**Example:**

::::CodeDrawer{title="logout" isResponseExpanded="false" autoGeneratedAnchorSlug="logout-1" legacyHash="fEfHDzjwb1d0Jr6QzEFWC"}
:::CodeblockTabsExamples
```javascript
await logout()
```
:::

:::CodeblockTabsResponses
```javascript
```
:::
::::

### recover()

Sends a Shopify reset password email to the customer.

**Example:**

::::CodeDrawer{title="recover" isResponseExpanded="false" autoGeneratedAnchorSlug="recover-1" legacyHash="hpxEQHDWpEGcoDxNMiFe9"}
:::CodeblockTabsExamples
```javascript
await recover('test@test.com')
```
:::

:::CodeblockTabsResponses
```javascript
```
:::
::::

### register()

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

**Example:**

::::CodeDrawer{title="register" isResponseExpanded="false" autoGeneratedAnchorSlug="register-1" legacyHash="1ImGMkDe7X_8tqTu451n2"}
:::CodeblockTabsExamples
```javascript
await register({ email: 'test@test.com', password: 'testtest' })
```
:::

:::CodeblockTabsResponses
```javascript
```
:::
::::

### resetPassword()

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

**Example:**

::::CodeDrawer{title="resetPassword" isResponseExpanded="false" autoGeneratedAnchorSlug="resetpassword-1" legacyHash="SD8QG09PPnN5cdeV5sdA6"}
:::CodeblockTabsExamples
```javascript
await resetPassword({
  id: 'id',
  password: 'testtests', // the new password
  token: '123'
})
```
:::

:::CodeblockTabsResponses
```javascript
```
:::
::::
