---
title: useShopifyCookies
description: Sets Shopify user and session cookies and refreshes the expiry time.
api_version: 2026-04
source_url:
  html: 'https://shopify.dev/docs/api/hydrogen-react/latest/hooks/useshopifycookies'
  md: >-
    https://shopify.dev/docs/api/hydrogen-react/latest/hooks/useshopifycookies.md
api_name: hydrogen-react
---

# use​Shopify​Cookies

Sets Shopify user and session cookies and refreshes the expiry time. Returns `true` when cookies are ready.

## use​Shopify​Cookies(**[options](#useshopifycookies-propertydetail-options)**​)

Optionally refreshes backend-managed cookies for standalone integrations. The Customer Privacy API owns tracking values and legacy cookie expiration.

If `fetchTrackingValues` is true, this sends a consent request through the Storefront API proxy, retrying against `checkoutDomain` if provided. Hydrogen's built-in analytics already delegates consent initialization to the Customer Privacy API and does not use this hook.

### Parameters

* **options**

  **UseShopifyCookiesOptions**

### Returns**boolean**

* `true` when the consent request has settled and cookies are ready.

### UseShopifyCookiesOptions

* checkoutDomain

  The checkout domain used if the same-origin consent request fails.

  ```ts
  string
  ```

* domain

  ```ts
  string
  ```

* fetchTrackingValues

  ```ts
  boolean
  ```

* hasUserConsent

  ```ts
  boolean
  ```

* ignoreDeprecatedCookies

  ```ts
  boolean
  ```

* storefrontAccessToken

  ```ts
  string
  ```

### Examples

* #### Example code

  ##### Description

  I am the default example

  ##### JavaScript

  ```jsx
  import * as React from 'react';
  import {useShopifyCookies} from '@shopify/hydrogen-react';

  export default function App({Component, pageProps}) {
    // Returns true when cookies are ready
    const cookiesReady = useShopifyCookies({hasUserConsent: true});

    if (!cookiesReady) {
      return null;
    }

    return <Component {...pageProps} />;
  }
  ```

  ##### TypeScript

  ```tsx
  import * as React from 'react';
  import {useShopifyCookies} from '@shopify/hydrogen-react';

  export default function App({
    Component,
    pageProps,
  }: {
    Component: React.ComponentType;
    pageProps: object;
  }) {
    // Returns true when cookies are ready
    const cookiesReady = useShopifyCookies({hasUserConsent: true});

    if (!cookiesReady) {
      return null;
    }

    return <Component {...pageProps} />;
  }
  ```

***

## Related

[sendShopifyAnalytics](https://shopify.dev/docs/api/hydrogen-react/2026-04/utilities/sendshopifyanalytics)

[getClientBrowserParameters](https://shopify.dev/docs/api/hydrogen-react/2026-04/utilities/getclientbrowserparameters)

[getTrackingValues](https://shopify.dev/docs/api/hydrogen-react/2026-04/utilities/gettrackingvalues)

***
