How do I show different prices, language or phone numbers depending on where a visitor is?
Short answer: For a simple case, redirecting visitors from one country to a specific page, you don't need anything beyond a plain redirect rule with a country condition, no code at all. For genuinely dynamic personalization, changing the price, phone number or language shown on the same page based on where the visitor actually is, you need Netlify Edge Functions, which run code at the network location nearest the visitor to modify the page on the fly.
Different markets need different prices, numbers or language, and you want to know how much engineering that actually requires.
I'm Ranjit, and I run Blur Studio: 15+ years building software, 120 apps taken live, and clients who have gone on to raise $10M+. I build AI systems and processes that help businesses do a lot more with a lot less time. I also work differently from most of what else is out there, more on that further down this page. Say hello.
This page may contain affiliate links from which Blur Studio earns commissions.
This is a case where the right answer genuinely depends on how dynamic your need is, and getting that wrong in either direction costs you: over-engineering a simple redirect, or under-building something that actually needs real logic. Working out which one you actually have is worth doing before writing a single line of code.
Check if a plain redirect rule is enough first
If your actual need is "send UAE visitors to the Dubai page, UK visitors to the UK page," that's a redirect with a country condition, no code involved at all:
# In netlify.toml
[[redirects]]
from = "/pricing"
to = "/pricing/uae"
status = 302
conditions = {Country = ["AE"]}
Netlify, the hosting platform the file above assumes your site is built and published on, runs a redirect engine that supports conditions by country, language, user role and cookie value directly in the rule, processed before the page even loads for the visitor. For a straightforward "send this country here" need, this is genuinely the entire solution, and it's worth confirming this covers your case before reaching for anything more involved.
When you actually need Edge Functions
A redirect sends the visitor to a different page. It can't change the content of one page based on where the visitor is, show the same pricing page but with AED instead of GBP, or swap a UK phone number for a UAE one on an otherwise identical layout. That's a genuinely different, more dynamic kind of problem, and it's what Netlify Edge Functions are built for.
An Edge Function runs at the network location nearest the visitor, before the page fully loads, and can inspect where the request is coming from (via Netlify's own geolocation context) to modify the response: rewrite a price, swap text, insert a different phone number, all on the same URL rather than redirecting to a separate page.
The real technical limits, so you don't design around the wrong assumptions
Netlify's own documentation sets specific, fairly tight limits for Edge Functions, worth knowing before you plan anything complex:
- 20MB code size after compression, for the whole set of edge functions on a site.
- 512MB memory shared across the deployed edge functions.
- 50 milliseconds of CPU execution time per request. This is genuinely tight, and it rules out any heavy processing; an edge function needs to do something fast and simple, like swapping a price or a phone number, not running a complex calculation.
- Not compatible with split testing, custom headers (including basic auth), or prerendering. If your site uses any of those features on the same paths, the edge function won't run as expected there.
That last point matters in practice more than it sounds: if you're already running an A/B test on your pricing page and then try to add an edge function for country-based pricing on the same page, the two features conflict, and you'll need to choose one or restructure how you're running the test.
A realistic example
Say you sell a service at a price shown as a round number in USD, but want Dubai-based visitors to see it in AED and UK visitors in GBP, converted at rates you control rather than letting a browser's locale guess do it inconsistently. An edge function can detect the visitor's country from Netlify's geolocation context, pick the right currency and rate from a small lookup table in your code, and rewrite that one number on the page, all within the tight CPU budget, since a currency lookup and a string replacement is exactly the kind of fast, simple operation edge functions are built for.
A worked example: a consulting firm with two offices and one website
A consulting firm with offices in London and Dubai wanted their "contact us" phone number to automatically show the local office's number depending on where the visitor was browsing from, while keeping everything else on the page identical. This wasn't a redirect case, since redirecting to two entirely separate page copies just to swap one phone number would mean maintaining two nearly identical pages and remembering to update both every time anything else on the page changed.
An edge function solved this cleanly and stayed well within the tight CPU budget: it checks the visitor's country from Netlify's geolocation context, picks the right phone number from a two-entry lookup, and swaps it into the page before it loads. The entire operation is a lookup and a string replacement, nowhere close to the 50-millisecond limit, and the firm now maintains one page instead of two, with the location-specific detail handled automatically rather than manually kept in sync across duplicate pages.
Common mistakes with geo-targeting
- Building an edge function for something a redirect already solves. If you genuinely just need different visitors landing on different pages, a redirect condition does that with zero code and zero ongoing maintenance.
- Trying to run heavy logic inside the 50-millisecond budget. Anything beyond a quick lookup and swap risks timing out. Keep edge function logic deliberately minimal.
- Not testing from an actual location, or a VPN set to one. Geo-targeting bugs are easy to miss testing from your own usual location; verify the behavior from (or simulating) each target country before considering it done.
What I'd actually tell you
Most requests I hear that sound like "I need geo-targeting" turn out to be the simple redirect case once we talk through it: send this market here, that market there. Don't build an edge function for that; it's solving a harder problem than you actually have. Reach for edge functions specifically when the content needs to change on the same page based on location, not when a different page per market would do the job just as well with far less to maintain.
When to skip this entirely
If you're already running an ecommerce platform like Shopify, its built-in Markets feature handles multi-currency and multi-region pricing natively, often better than a custom edge function would, since it's purpose-built for exactly that. Don't build custom geo-logic on top of a platform that already solves the problem natively, since you'd be maintaining a parallel system doing something the platform you're already paying for already does reliably.
How I'd approach this
I'd start by confirming which of these two problems you actually have, since they have very different right answers. If it's "send this market to a different page," that's a five-minute redirect rule, not a project. If it's genuine same-page personalization by location, Netlify Edge Functions are the right tool and I build this kind of thing regularly, kept well within the tight CPU budget by doing the lookup and swap quickly rather than anything heavier.
Questions people ask
Do I need Edge Functions to redirect visitors by country?
No. A plain redirect rule with a country condition in netlify.toml handles that with no code at all. Edge Functions are for changing content on the same page based on location, not sending visitors to a different page.
How fast does an Edge Function actually need to run?
Netlify caps CPU execution time at 50 milliseconds per request, which is genuinely tight. Edge functions need to do something fast and simple, like swapping a price or phone number, not heavy processing.
Can I run an Edge Function and an A/B test on the same page?
No, Netlify's documentation states edge functions aren't compatible with split testing on the same paths. If you need both, you'll need to restructure how the test runs or separate the two features onto different paths.
What can an Edge Function actually see about a visitor?
Netlify provides a geolocation context to the function, typically country-level location data derived from the request, which the function can use to decide what to show without needing a separate third-party geolocation service.
Is Shopify Markets a better option for an online store?
Often yes, if you're already on Shopify. Markets handles multi-currency and multi-region pricing natively within the platform, which is usually simpler and more reliable than building custom geo-logic on top of it.
What's the maximum amount of code I can run in an Edge Function?
20MB after compression, for the full set of edge functions deployed on a site, with 512MB of memory shared across them. For the kind of fast, simple content swap most sites need, this is comfortably enough.