--- title: useShopifyCookies description: >- Sets Shopify user and session cookies and refreshes the expiry time. Returns `true` when cookies are ready. api_version: 2026-01 api_name: hydrogen-react 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 --- # 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)**​) Manages Shopify cookies. If `hasUserConsent` option is false, deprecated cookies will be removed. Returns `true` when cookies are ready. ### Parameters * **options** **UseShopifyCookiesOptions** ### Returns**boolean** * `true` when cookies are set and ready. ### UseShopifyCookiesOptions ```ts CoreShopifyCookiesOptions & { /** * If set to `false`, Shopify cookies will be removed. * If set to `true`, Shopify unique user token cookie will have cookie expiry of 1 year. * Defaults to false. **/ hasUserConsent?: boolean; /** * The domain scope of the cookie. Defaults to empty string. **/ domain?: string; /** * The checkout domain of the shop. Defaults to empty string. If set, the cookie domain will check if it can be set with the checkout domain. */ checkoutDomain?: string; /** * If set to `true`, it skips modifying the deprecated shopify_y and shopify_s cookies. */ ignoreDeprecatedCookies?: boolean; } ``` ### CoreShopifyCookiesOptions * checkoutDomain ```ts string ``` * fetchTrackingValues ```ts boolean ``` * storefrontAccessToken ```ts string ``` Examples ### 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 ; } ``` ##### 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 ; } ``` ## Related [Utility - sendShopifyAnalytics](https://shopify.dev/api/hydrogen-react/utilities/sendShopifyAnalytics) [Utility - getClientBrowserParameters](https://shopify.dev/api/hydrogen-react/utilities/getclientbrowserparameters) [Utility - getTrackingValues](https://shopify.dev/api/hydrogen-react/utilities/getTrackingValues)