> 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/useuser.md).

# useUser

The `useUser` hook returns a series of methods for managing a Shopify customer account. The customer must have an active authentication session (see `useAuth`) for these methods to work.

{% code title="useUser" %}

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

const {
  user,
  status,
  createUserAddress,
  loadUser,
  modifyUserAddress,
  modifyUserDefaultAddress,
  removeUserAddress
} = useUser()
```

{% endcode %}

### user

Represents the current user.

**Example:**

{% code title="user" %}

```javascript
const { user } = useUser()
```

{% endcode %}

### status

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

**Example:**

{% code title="status" %}

```javascript
import { useUser, UserStatus } from '@chordcommerce/gatsby-theme-performance'

const { status } = useUser()

if (status === UserStatus.Failed) {
  // the user could not be loaded, probably because there is no valid authentication session
}
```

{% endcode %}

### createUserAddress()

Adds a new address to the Shopify customer's address book.

**Example:**

{% code title="createUserAddress" %}

```javascript
const address = {
  address1: '',
  address2: '',
  city: '',
  company: '',
  country: '',
  firstName: '',
  lastName: '',
  phone: '',
  province: '',
  zip: ''
}
const isDefaultAddress = false
await createUserAddress(address, isDefaultAddress)
```

{% endcode %}

### loadUser()

Reloads the current user. This is automatically called on every page load and with every other `useUser` method.

**Example:**

{% code title="loadUser" %}

```javascript
await loadUser()
```

{% endcode %}

### modifyUserAddress()

Updates an address in the Shopify customer's address book.

**Example:**

{% code title="modifyUserAddress" %}

```javascript
const addressId = '123'
const address = {
  address1: '',
  address2: '',
  city: '',
  company: '',
  country: '',
  firstName: '',
  lastName: '',
  phone: '',
  province: '',
  zip: ''
}
const isDefaultAddress = false
await modifyUserAddress(addressId, address, isDefaultAddress)
```

{% endcode %}

### modifyUserDefaultAddress()

Updates which address is marked as the default address in the Shopify customer's address book.

**Example:**

{% code title="modifyUserDefaultAddress" %}

```javascript
const addressId = '123'
await modifyUserDefaultAddress(addressId)
```

{% endcode %}

### removeUserAddress()

Removes an address from the Shopify customer's address book.

**Example:**

{% code title="removeUserAddress" %}

```javascript
const addressId = '123'
await removeUserAddress(addressId)
```

{% 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/useuser.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.
