---
title: Shopify Markets
description: Add regional locale routing and localized commerce with Shopify Markets.
url: "https://vercel.shop/docs/skills/enable-shopify-markets"
docs_index: /llms.txt
lastUpdated: 2026-12-05
type: guide
---

> For an index of all documentation, see [/llms.txt](/llms.txt).

## How to use

Ask your agent to use the `enable-shopify-markets` skill, or run it as a slash command in Claude Code:

```text
/enable-shopify-markets
```

<div className="pb-6" />

# Enable Shopify Markets

Add multi-region commerce to the Vercel Shop template. The fresh baseline is one deployment with clean URLs, inline copy beside each component, and explicit `shopConfig.localization = { country: "US", language: "EN", locale: "en-US" }`; it has no next-intl, catalogs, or `lib/i18n/`.

This skill couples copy and market: a validated regional locale such as `en-US`, `en-CA`, or `fr-CA` selects both translated copy and the Shopify country and language. Confirm that coupling fits the store. An installation that already separates language and country, or a copy-only `enable-i18n` installation with a fixed commerce country, keeps its model, translations, and routing; get approval before adding coupling or changing public URLs. In a noninteractive run, stop and report unresolved routing or market-model choices.

Do not add a market key, market-to-locale map, currency map, or `/market/locale` route such as `/ca/fr-CA/products/shoe`. Existing custom market models need an explicit migration decision, not automatic removal.

`enable-i18n` owns the copy and routing mechanics: next-intl wiring, `routing` in `lib/i18n/index.ts`, extracted catalogs, the move into `app/[locale]`, the root-param request config, localized `Link` hrefs, Cache Components traps, proxy composition, and `buildAlternates`. Run its steps first and keep its rules except where this skill replaces them; this skill adds the market model.

For any Shopify GraphQL edit, use Shopify AI Toolkit to confirm current API facts and validate the complete operation, then follow `shopify-graphql-reference` for this template's placement, transforms, cache role, locale flow, and invalidation. Read every Storefront API operation and cache wrapper, `lib/shopify/i18n/index.ts` and every `getShopifyI18n` call, cart creation and buyer identity updates, Customer Account auth context, Shopify analytics, the agent instructions and tools, and the SEO and sitemap routes, since each carries commerce context.

## 1. Ask for routing and locales

If the user has not already decided, ask which strategy they want:

1. **Locale sub-path**: one regional locale segment, such as `/fr-CA/products/shoe`. Ask whether the default locale is `as-needed` (`/products/...`) or `always` (`/en-US/products/...`).
2. **Invisible cookie**: every locale serves `/products/shoe`, and next-intl rewrites internally to `/[locale]/...` from the locale cookie. Before choosing it, state its tradeoffs: every locale shares one canonical URL, so search engines and shared links cannot target a locale, and a first visit gets the locale matching the browser's `Accept-Language`, not Shopify's geolocated market.
3. **Per-domain**: domains select the available and default locales, such as `example.ca/fr-CA/products/shoe` or a single locale on `example.fr/products/shoe`. Paths carry a prefix only when a domain serves several locales.

Then ask for the default locale and every enabled locale as regional BCP 47 tags, such as `en-US, en-CA, fr-CA, de-DE`. Do not accept bare tags such as `en` or `fr`, and do not ask for a market identifier or currency.

## 2. Make regional locales the source of truth

`routing` in `lib/i18n/index.ts`, created by `enable-i18n` "Wire next-intl", stays the only locale list: use regional tags and the strategy from Step 4, and keep its `Locale` type from `AppConfig`. Seed the default from `shopConfig.localization`; if its explicit country/language and formatting locale disagree, resolve that deliberately instead of deriving a different market silently. Extend an existing source of truth without resetting values.

Derive Shopify context from the validated locale beside `routing`:

```ts
import type { Locale } from "next-intl";

import type { CommerceLocale } from "@/lib/config/types";

export const LOCALE_COOKIE_NAME = "NEXT_LOCALE";

export function getCountryCode(locale: Locale): CommerceLocale["country"] {
  const country = new Intl.Locale(locale).region;
  if (country === "US" || country === "CA") return country;
  throw new Error(`Unsupported commerce country: ${country}`);
}

export function getLanguageCode(locale: Locale): CommerceLocale["language"] {
  const language = new Intl.Locale(locale).language.toUpperCase();
  if (language === "EN" || language === "FR") return language;
  throw new Error(`Unsupported commerce language: ${language}`);
}

export function getCommerceLocale(locale: Locale): CommerceLocale {
  return { country: getCountryCode(locale), language: getLanguageCode(locale) };
}
```

These guards cover only the example locales. Extend them for the store's approved countries and languages, and validate each conversion with Shopify AI Toolkit; an uppercased BCP 47 language is not always a Shopify language code.

Request bodies, cookies, headers, route params, and query params stay untrusted strings until `hasLocale(routing.locales, value)` passes; reject unsupported values instead of casting them to `Locale`. Operation `locale` options take a `CommerceLocale` object (`{ country, language }` from `lib/config/types.ts`), not the routing `Locale` string: convert once with `getCommerceLocale` at the validated boundary and pass the object through existing operation and cache inputs. For an older customized transport, adapt its actual signature instead of replacing it.

### Currency rule

Currency always comes from Shopify's localized response (`MoneyV2.currencyCode`, cart cost, product prices, etc.). Never infer currency from locale and never add `localeCurrency`, `marketCurrency`, or a locale-to-currency lookup.

When UI outside a price object needs a currency code, pass one from fetched Shopify data. If Shopify returns no product or cart from which to derive it, omit currency-specific UI rather than guessing.

## 3. Install next-intl and migrate copy

Follow `enable-i18n` "Wire next-intl" and "Translate copy in place", without forcing `localePrefix: "always"`. Regional variants that share copy, such as `en-US` and `en-CA`, can share one catalog: list only the catalogs you translate in `messages.locales`, and map each variant to its catalog file in the request config. Commerce context does not translate storefront labels.

## 4. Configure routing

Configure `routing` in `lib/i18n/index.ts` for the chosen strategy. `enable-i18n` "Wire next-intl" creates the navigation module from it.

### Locale sub-path

```ts
export const routing = defineRouting({
  alternateLinks: false,
  defaultLocale: "en-US",
  localeCookie: { name: LOCALE_COOKIE_NAME, sameSite: "lax" },
  localePrefix: "as-needed", // or "always"
  locales: ["en-US", "en-CA", "fr-CA"],
});
```

### Invisible cookie routing

```ts
export const routing = defineRouting({
  alternateLinks: false,
  defaultLocale: "en-US",
  localeCookie: { name: LOCALE_COOKIE_NAME, sameSite: "lax" },
  localeDetection: true,
  localePrefix: "never",
  locales: ["en-US", "en-CA", "fr-CA"],
});
```

next-intl resolves the cookie, then `Accept-Language`, then the default, and rewrites `/products/shoe` internally to a route such as `/fr-CA/products/shoe`; the browser URL does not change. Do not add a second market rewrite on top.

### Per-domain routing

```ts
export const routing = defineRouting({
  alternateLinks: false,
  defaultLocale: "en-US",
  domains: [
    { defaultLocale: "en-US", domain: "example.com", locales: ["en-US"] },
    { defaultLocale: "en-CA", domain: "example.ca", locales: ["en-CA", "fr-CA"] },
  ],
  localeCookie: { name: LOCALE_COOKIE_NAME, sameSite: "lax" },
  localePrefix: "as-needed",
  locales: ["en-US", "en-CA", "fr-CA"],
});
```

Shopify country and language still derive from the resolved locale; `domains` is routing, not a market model.

Keep `Link` from `@/components/ui/link`; `enable-i18n` "Links and redirects" localizes its hrefs with `getPathname`, which follows the configured strategy. `getPathname` returns a path, so a link or alternate for a locale on another host needs that locale's `domain` from `routing.domains` prepended.

## 5. Move routes and resolve the locale

Move the routes as `enable-i18n` "Move routes under `app/[locale]/`" describes, keeping the paths it lists unlocalized, with `generateStaticParams` from `routing.locales` and every moved export, including `export const ensureStatic = "prefetch"`.

Server Components read the locale with `getLocale()` from `next-intl/server`, which the `enable-i18n` request config resolves from the root param, and pass `getCommerceLocale(await getLocale())` to operations. Do not add `setRequestLocale`. Route Handlers and Server Actions have no root param: validate the locale from their input. Keep API, OAuth, markdown, and chat handling outside the Server Component request config. `enable-i18n` "Cache Components traps" lists the resulting build errors and bare-`/` behavior.

## 6. Extend the proxy

Hydrogen's cart and predictive-search handlers apply `@inContext(country, language)` from the request context's locale. Its Customer Account client fills only a declared `$language: LanguageCode` variable, so declare it in account documents that should follow the market. The template builds request contexts with `getShopifyI18n(shopConfig.localization)` from `lib/shopify/i18n/index.ts`, pinning them to the deployment's market, in `createCustomerRequestContext` (`lib/auth/request.ts`) and in the server cart seed (`lib/cart/server.ts`). Accept the validated commerce context in both and pass it to `getShopifyI18n` instead. Resolve the locale before Shopify dispatch (`resolveRequestLocale`, built on `hasLocale(routing.locales, value)`): from the validated locale prefix when the path has one, otherwise the validated locale cookie (unprefixed handler paths such as `/api/cart` carry no locale segment), otherwise `routing.defaultLocale`.

Keep `getShopifyI18n` returning one single-locale definition per commerce context in every routing strategy. Do not add `routing` to a `defineShopifyI18n` definition or let Hydrogen match the locale from the URL: its `pathname` routing serves the default locale unprefixed only and resolves unprefixed handler paths to the default, its `domain` routing allows one locale per hostname, neither reads the locale cookie, and a routed locale gives Hydrogen its own lowercase path prefix, such as `/fr-ca`, for the URLs it builds. Unprefixed `/api/cart` and `/api/predictive-search` requests therefore carry no locale prefix and need no `LocaleProvider`; if a path-prefixed storefront wraps the app in Hydrogen's `LocaleProvider` instead, keep the proxy matching those prefixed handler routes and resolving the market from the prefix.

Compose next-intl after Shopify dispatch and Markdown negotiation exactly as `enable-i18n` "Proxy" shows. The one Markets change is the context built before dispatch:

```ts
const locale = resolveRequestLocale(request);
const requestContext = createCustomerRequestContext(request, getCommerceLocale(locale));
// Keep the template's customerSession, isAuthPath, routeOptions, Shopify dispatch, and
// Markdown negotiation, then compose next-intl as enable-i18n "Proxy" shows.
```

Keep the template matcher and the `enable-i18n` "Proxy" path gate in all three routing modes; they keep app Route Handlers, webhooks, Eve, and static files out of locale negotiation. In invisible-cookie mode, next-intl's `never` mode canonicalizes direct locale-prefixed URLs back to the clean path; do not expose the internal rewrite destination in links, metadata, or redirects.

## 7. Propagate locale through commerce

Audit definitions and real callers. Localized Storefront API operations receive the validated commerce context and use Shopify's `@inContext(country: $country, language: $language)`. Inspect existing locale and cache inputs before adding arguments, and preserve intentional ones even where presentation does not use them. This includes:

- products, collections, search, recommendations, and complementary products
- navigation menus added by `enable-shopify-menus`
- cart creation: `createEmptyCart` in `lib/cart/server.ts` sets `buyerIdentity.countryCode` from `shopConfig.localization`; use the request context's country
- sitemap catalog output
- Shopify analytics: `components/analytics/index.tsx` builds the `ShopifyScriptsTracker` `i18n` from `shopConfig.localization`
- every other request context built with `getShopifyI18n(shopConfig.localization)`: Customer Account requests, the not-found redirect lookup, and the agent's cart helpers in `agent/lib/cart.ts`

Cached functions must receive `locale` explicitly. Never read the locale cookie, `headers()`, or `cookies()` inside a `"use cache"` function. The locale argument separates cache entries; do not add a parallel market cache key.

Keep locale defaults only at compatibility boundaries the single-locale template needs. Once a route has resolved locale, pass it explicitly rather than defaulting deeper in the stack.

### Menus

If `enable-shopify-menus` has added `getMenu`, pass the validated commerce context as `getMenu({ handle, locale })` from every caller; its query already carries `@inContext`. Without this, navigation remains pinned to the default market.

### Customer Account auth

Pass the active validated commerce context to `getShopifyI18n` for the Shopify/Hydrogen request context instead of pinning it to `shopConfig.localization` or an older `defaultLocale`. Preserve locale across login, authorize, refresh, and logout return URLs. Validate any locale carried through OAuth state or URL params.

### Chat and agent API

Shop Agent is disabled by default. Preserve that setting; enabling Markets must not enable chat. When chat is enabled, inspect `agent/channels/eve.ts`, `agent/tools/`, `agent/lib/`, and the Shopify connections rather than adding an app-owned chat route or commerce HTTP bridge.

Eve's session routes live outside `[locale]`, and invisible URLs do not reveal locale in the referer. Carry the selected locale explicitly, validate it against `routing.locales` during cart setup and in Eve's channel, and never infer it from URL segments or fall back unconditionally to `defaultLocale`. Client context can describe the page, but must not select an arbitrary cart or an unsupported locale.

Thread the session's validated locale through everything that reads `shopConfig.localization` today: the market `agent/instructions.ts` states to the model, the cart helpers, and the catalog and policy searches in `agent/tools/search-products.ts` and `agent/tools/search-policies.ts`. Shopify's catalog `context.language` takes the BCP 47 locale, not the `CommerceLocale` language. Eve uses the shared uncached Shopify catalog operations and Hydrogen handlers, never Next.js request or cache APIs.

### Markdown mirrors

Mirrors keep the deployment market, as `enable-i18n` "SEO, sitemap, and Markdown" describes: `app/md` responses are publicly cached per path, not per locale. Preserve `?variant=` and search parameters through the rewrite.

## 8. Switch locale and carry the market to the cart

In Markets mode a locale switch changes the market, which replaces `enable-i18n`'s rule that switching language never touches the cart, country, or currency.

Cart writes stay in Hydrogen's `/api/cart` handler; never mutate the cart from a Server Action or a custom route. The proxy builds the handler's request context from the selected locale (Step 6), so cart requests after a switch run in the new market. Only the cart GET reconciles a mismatched `buyerIdentity.countryCode`, with `cartBuyerIdentityUpdate`, keeping email and phone and leaving B2B carts unchanged. A failed reconcile is logged and returns the old cart, so read the cart after a country change and check its country and currency:

- `fr-CA` to `en-CA`: copy and Shopify language change; the country stays `CA`.
- `en-CA` to `en-US`: reading the cart runs with country `US`, resets the cart's buyer country, and returns prices in the new market's currency.

The selector remains a leaf Client Component. A Server Action in `lib/i18n/action.ts` parses the requested locale with a module-private `zod` schema that accepts only `routing.locales` values, then sets the locale cookie; it never reads or writes the cart. After a country change, call `refresh()` from `useCartActions()` so prices and checkout reflect Shopify's response for the new market; do not invalidate public cache tags.

- **Sub-path/per-domain:** use next-intl's client router to replace the current pathname with `{ locale: nextLocale }`, then refresh the cart.
- **Invisible cookie:** call the action, then call `router.refresh()` and refresh the cart. The pathname must not change.

Do not offer a separate currency selector unless the store has a Shopify-backed currency choice independent of country. Display currency from cart/product responses.

## 9. Strategy-specific SEO and sitemap behavior

**Locale sub-path or per-domain:** follow `enable-i18n` "SEO, sitemap, and Markdown" for localized canonicals, `hreflang` alternates with `x-default`, and one sitemap URL per locale, built with `getPathname` rather than `` `/$\{locale\}` ``. Per-domain URLs also need each locale's host: canonicals, alternates, sitemaps, `robots.ts`, and `metadataBase` read `shopConfig.site.url`, so derive the host from the locale's entry in `routing.domains`.

**Invisible cookie:** all locales share one public URL.

- Canonical is the clean public path.
- Do not emit locale-specific `hreflang` URLs.
- Emit one sitemap URL per resource, not one per locale.
- Keep `alternateLinks: false` in next-intl routing.
- Treat localization as personalization: shared links and crawlers without the cookie receive negotiated or default content.

Never put internal `/[locale]/...` rewrite targets into metadata or sitemap XML.

## 10. Verification

Run from the storefront root, then run the app and verify the selected strategy:

```bash
pnpm check
pnpm build
```

### All strategies

- Every enabled locale produces the expected Shopify country and language, and products, cart, and agent results show Shopify's currency for it.
- Public caches separate localized products, prices, and menus; carts remain uncached.
- `fr-CA` to `en-CA` keeps the cart's country `CA`; `en-CA` to `en-US` reads the cart back with buyer country `US` and US prices, and every cart write goes through `/api/cart`.
- Variant and filter query parameters survive switching and rewrites.
- Existing localized installations keep their translations, routing, and approved commerce model.

### Locale sub-path

- Locale URLs serve directly, and default-prefix behavior matches `always` or `as-needed`.
- Canonical, hreflang, and sitemap URLs are locale-specific.

### Invisible cookie

```bash
curl -I http://localhost:3000/products/example
curl -I --cookie "NEXT_LOCALE=fr-CA" http://localhost:3000/products/example
```

- Both requests keep `/products/example` as the public URL.
- The cookie-selected response has `<html lang="fr-CA">` and Shopify country `CA` context.
- Locale switching changes content and cart context without changing the address bar.
- `/fr-CA/products/example` does not remain a public canonical URL.
- Metadata and sitemap contain only clean public paths and no locale alternates.

### Per-domain

- Each configured host resolves its allowed and default locales.
- Cross-domain locale switching uses the correct host.
- Canonical and hreflang URLs contain each locale's production domain.

---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/llms.txt](/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/agents.md](/agents.md)