Skip to main content

Shopify Markets

If your store uses Shopify Markets to sell in multiple countries/regions, you can configure Fast Simon to return only products available in a specific market.

How It Works

Pass the marketContext option when creating the Fast Simon client. This sends a market_context query parameter with every API request (search, collections, autocomplete, recommendations, visual similarity), so the API returns only products published to that market.

When marketContext is omitted, no market filtering is applied and all products are returned — the default behavior.

Setup

In your context file (e.g., /app/lib/context.ts or server.ts), pass the shopper's country code from Hydrogen's locale detection:

import {createFastSimonClient, FastSimonSession} from '@fast-simon/storefront-kit';

export async function createAppLoadContext(
request: Request,
env: Env,
executionContext: ExecutionContext
) {
const waitUntil = (p: Promise<any>) => executionContext.waitUntil(p);

const [cache, session, fastSimonSession] = await Promise.all([
caches.open('hydrogen'),
AppSession.init(request, [env.SESSION_SECRET]),
FastSimonSession.init(request, [env.SESSION_SECRET]),
]);

// Get the locale from the request (country, language, currency)
const locale = getLocaleFromRequest(request);

const fastSimon = createFastSimonClient({
cache,
waitUntil,
request,
uuid: '{{fast_simon_uuid}}',
storeID: '{{fast_simon_store_id}}',
fastSimonSession,
searchPersonalization: true,
collectionPersonalization: true,
marketContext: locale.country, // e.g. "US", "CA", "GB", "FR"
});

return {
...hydrogenContext,
fastSimon,
fastSimonSession,
};
}
note

The locale.country value typically comes from Hydrogen's built-in i18n support or a custom getLocaleFromRequest helper that reads the locale from the URL path, cookies, or request headers.

Affected Endpoints

When marketContext is set, the following API calls include market filtering:

MethodAPI Endpoint
getSearchResults/full_text_search
getSmartCollection/categories_navigation
getAutocompleteResults/pop, autocomplete products, articles
getVisualSimilarityProducts/related_products_suggest
productsRecommendations/upsell_cross_sell_recommendation
getRecommendations/upsell_cross_sell_recommendation

Multi-Language Stores

If your store has separate Fast Simon store IDs per language (common with Shopify Markets), you can combine both language-based store selection and market context:

function getFastSimonConfig(language: string) {
const isEnglish = language.toLowerCase() !== 'fr';
return {
storeId: isEnglish ? '101110' : '102114',
uuid: 'your-uuid-here',
};
}

const locale = getLocaleFromRequest(request);
const config = getFastSimonConfig(locale.language);

const fastSimon = createFastSimonClient({
cache,
waitUntil,
request,
uuid: config.uuid,
storeID: config.storeId,
fastSimonSession,
marketContext: locale.country,
});

Requirements

  • @fast-simon/storefront-kit version 1.5.0 or higher
  • Shopify Markets configured in your Shopify admin
  • Fast Simon enabled for the relevant markets in your Fast Simon dashboard