Geolocation redirects on Hydrogen and headless Shopify
By Beacon Wave Studio · · 7 min read
The question arrives in two forms. A developer building a Hydrogen storefront asks whether GeoBeacon can be added to it. A merchant whose agency has proposed going headless asks whether the country popup they already have will survive the move. The answer to both is the same and it is worth being direct about it: GeoBeacon runs inside Online Store themes and nowhere else. This post explains why that is, what Shopify gives you on Hydrogen instead, and how the two coexist when a store runs both.
Why a theme app embed stops at the theme
GeoBeacon is delivered as a theme app extension, specifically an app embed block that you switch on in the theme editor. Shopify injects it into every page the Online Store renders, which is what lets the app detect a visitor, show the popup and redirect without you editing Liquid. The theme app extension documentation describes that mechanism, and the key word in it is theme. A headless storefront does not render Online Store pages, so there is no theme for Shopify to inject the embed into. The block simply never runs.
The detection step depends on the theme too. GeoBeacon asks the storefront for Shopify's own browsing context suggestions, the same signal Shopify uses to recommend a market and language, which is served from your online store domain. A Hydrogen app on its own domain has no such endpoint to call, and the script that would call it is not there either. We could ship a snippet for people to paste into a Remix app, but it would be a different product with a different support story, and we have chosen not to pretend otherwise.
What Hydrogen offers instead
Shopify has thought about this for headless, and its guidance is deliberately different from a redirect app. The Hydrogen Markets documentation recommends encoding the market in the URL, either as a path prefix such as /en-ca or as a separate domain per market, and treating that URL as the source of truth for pricing, currency and language. The storefront reads the locale from the request and queries the Storefront API with the matching country and language codes.
For letting the visitor change market, the country selector guide shows a form that posts the chosen locale to a route, which updates the cart buyer identity and redirects to the localized URL. That is the headless equivalent of a shopper clicking a flag in a theme.
On automatic detection the Hydrogen docs are cautious. They suggest using headers, cookies or query parameters to improve the experience, for example by showing a banner that invites the shopper to switch, rather than silently redirecting on the first request. Storefronts hosted on Oxygen receive the buyer location in request headers, so the raw ingredient is there; the decision about what to do with it is yours to code. If you have read our posts on popup versus automatic redirect, the trade-offs are identical, only the implementer changes.
What you are rebuilding
A fair way to size the work is to list what GeoBeacon does on a theme and ask which parts a Hydrogen storefront needs. Detection, as above, comes from Oxygen headers or a third party IP service. The popup or redirect is a component plus a route. Remembering the choice so the visitor is not asked again is a cookie. Skipping bots, crawlers and link previewers matters as much on Hydrogen as on a theme, because a redirect served to Googlebot is still a redirect served to Googlebot; our SEO post applies unchanged. Keeping the page path across the switch, not interrupting a visitor who arrived from your own other store, and excluding checkout and account pages are each a few lines, but they are the lines that get forgotten.
None of it is hard for a team that is already building a Hydrogen storefront. It is simply not free, and it is not something an app from the Shopify App Store will drop in for you.
Mixed setups: where GeoBeacon still fits
Plenty of stores are not all one thing. The patterns we see most often:
- Hydrogen for the home market, themes for the rest. The flagship storefront is headless and the regional stores are Online Store expansion stores or markets with their own domains. GeoBeacon runs on the themed stores and can route visitors who land there to the Hydrogen storefront with a URL rule, the same kind used to send a country to a distributor. Visitors who land on the Hydrogen side first are the headless code's responsibility.
- Headless shop, Online Store blog. The blog and content pages stay on the theme for the editor and the apps. A GeoBeacon rule on those pages can send a visitor from another country to the right localized URL on the headless shop, and the page path option carries the slug across if the headless store mirrors it.
- Migrating in stages. During a move from themes to Hydrogen, one market goes first. Pause or edit the GeoBeacon rule for that market so it points at the new URL, leave the others alone, and the popup keeps working for everyone still on the theme.
In each case the rule is simple: GeoBeacon decides on pages the Online Store renders, and only there. Anything that happens after the visitor arrives on a headless page is the headless app's job.
Testing across the boundary
The ?geobeacon=XX test parameter and the console log described in the testing without a VPN post work on the themed pages only, since they are features of the embed. Use them to confirm that a themed page sends the right country to the right Hydrogen URL. Then test the landing on the Hydrogen side separately with whatever mechanism your code uses, and check that it does not immediately redirect the visitor back. A loop between a theme redirect and a headless redirect is the headless version of the loop in our redirect loop post, and the fix is the same: one side decides, the other side respects a remembered choice.
A note on Shopify Canvas and other new surfaces
The same theme boundary explains the answer in our Shopify Canvas post: when a surface renders through the Online Store, the embed runs; when it renders somewhere else, it does not. Headless is the clearest case of somewhere else. We will update this post if Shopify adds a way for theme app extensions to reach headless storefronts, but as of writing the documentation says they are for themes, and that is how GeoBeacon should be planned for.
Frequently asked questions
Does GeoBeacon work on a Hydrogen storefront?
No. GeoBeacon runs as a theme app embed inside an Online Store theme, and Hydrogen storefronts do not load theme app extensions. On Hydrogen the country selector and any automatic switch are part of your own Remix code, following the patterns in the Hydrogen Markets documentation.
Can I use GeoBeacon if only part of my site is headless?
Yes, on the Online Store part. A common setup is a Hydrogen storefront for one region and Online Store themes for the others, or an Online Store blog beside a headless shop. GeoBeacon runs on the themed pages and can send visitors to the Hydrogen storefront with a URL rule; the Hydrogen side needs its own detection for visitors who land there first.
How does Hydrogen detect a visitor's country without an app?
Shopify's Hydrogen documentation recommends deriving the locale from the URL path or domain, and offering a country selector that posts to a route which redirects and updates the cart buyer identity. Where the storefront is hosted on Oxygen, request headers carry the buyer's country, so you can show a banner suggesting a switch without a third party service.
Should I move to headless to get better geolocation?
Not for geolocation alone. The Online Store with Shopify Markets and a theme app embed already gives you country detection, a popup or redirect, remembered choices and exclusions without writing code. Headless makes sense for other reasons, and when you go that way, plan to build the locale switch yourself.