An open-source edge localization tool built on Cloudflare Workers. Drop it into any e-commerce stack to serve geo-aware pricing, currency, and language context in under 50ms.
Live Demo: https://geoglobal.belle888k.workers.dev
Source: https://github.com/BelleKou/geoglobal
E-commerce platforms serving global markets face a critical latency gap: origin servers in the US deliver ~400ms response times to APAC users, directly correlating with measurable drops in conversion rates.
Moved geo-aware decision logic to Cloudflare's edge network β 300+ nodes globally. Instead of round-tripping to a central server, localization, currency conversion, and pricing rules are resolved at the node closest to the user, cutting response time to <50ms regardless of location.
Technical Advantage: Significantly reduces first-screen latency for global users by resolving logic at the edge, skipping the traditional origin server round-trip.
- Serves localized currency, language, and timezone to users in <50ms globally
- Non-technical teams can update regional pricing in real time β no engineer, no redeployment
- Stays online even when third-party APIs go down β zero user-facing impact
- Covers 10+ markets out of the box; new market = one line of config
- Respects user choice over IP detection via manual preference override
- Runtime: Cloudflare Workers (edge compute, 300+ global nodes)
- Language: TypeScript
- Exchange Rate: ExchangeRate-API (with static fallback)
- Optional: Cloudflare KV (for remote discount config)
Returns full geo context for the current user.
Supports user preference override via header:
X-User-Country: CN
Response example:
{
"country": "CN",
"currency": "CNY",
"language": "zh-CN",
"timezone": "Asia/Shanghai",
"discount": 0,
"rate": 7.25,
"source": "ip",
"timestamp": "2026-03-12T10:00:00.000Z"
}Prerequisites: Node.js 18+, Cloudflare account (free tier works)
git clone https://github.com/BelleKou/geoglobal.git
cd geoglobal
npm install
npx wrangler devOpen http://localhost:8787/api β you'll see your geo context returned in under 50ms.
# 1. Deploy to Cloudflare Workers
npx wrangler deploy
# 2. (Optional) Enable KV discount control
npx wrangler kv namespace create GEO_CONFIG
# Add the KV id to wrangler.jsonc, then:
npx wrangler kv key put --binding=GEO_CONFIG "discount:CN" "15"| Decision | Reason |
|---|---|
| Cloudflare Workers | Edge runtime with native geo data, no third-party IP library needed |
| In-memory rate cache | Reduces external API calls, eliminates hard dependency on third-party uptime |
| Three-tier fallback | Any single point of failure must not affect user-side rendering |
| Config-driven country table | New market = one line of config, zero core logic changes |
| Optional KV discounts | Decouples pricing strategy from code β enable only when needed; allows non-technical teams to update regional pricing in real time without redeployment |
| CF Workers vs Lambda@Edge | ~0ms cold start, native geo data, no IP library needed vs Lambda@Edge 50-500ms cold start |
Evaluated three options before building:
| Option | Cold Start | Global Nodes | Native Geo Data | KV Storage | Verdict |
|---|---|---|---|---|---|
| Cloudflare Workers | ~0ms | 330+ | β Built-in | β Native | β Chosen |
| Lambda@Edge | 50-500ms | ~50 | β Needs library | β Needs DynamoDB | β Too slow |
| Fastly Compute | ~5ms | 60+ | β Needs library | β Separate setup | β Smaller network |
Cloudflare Workers was the only option with native geo data, near-zero cold start, built-in KV storage for remote discount config, and a global network large enough to serve APAC users consistently under 50ms β without any third-party dependencies.
- Interactive analytics dashboard β visualize real-time geo distribution of your users
- A/B testing hooks β run regional pricing experiments natively at the edge
- Multi-CDN fallback β support Fastly and CloudFront as backup providers
- Webhook support β trigger real-time discount updates without redeployment
PRs welcome. Open an issue first for major changes.
MIT