Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

edge-commerce

FreeNo executable scriptsNot checked

Reduce latency globally by running geo-routing, A/B tests, and personalization logic at the network edge using Cloudflare Workers or Vercel

finsilabsby finsilabs★ 69 GitHub stars

About this skill

Edge Commerce

Overview

Edge computing executes code in the CDN PoP closest to each user, reducing latency from hundreds of milliseconds (round-trip to a central origin) to under 50ms. For e-commerce, this enables geo-routing (redirect UK users to a UK storefront), edge-side personalization (inject user tier into cached pages), instant A/B testing without origin round-trips, and distributed inventory caching via edge KV stores.

When to Use This Skill

  • When pages routed through a central origin have high TTFB (>300ms) for international users
  • When you need to redirect users to region-specific storefronts or localized product catalogs
  • When you want to run A/B tests without adding JavaScript that delays page rendering
  • When building a multi-region deployment where each region needs its own origin but shares a single domain

Core Instructions

Step 1: Determine your platform and what edge computing can do for you

Platform Edge Capabilities How to Use Them
Shopify Shopify's CDN (Fastly) already serves stores from global edge locations Use Shopify Markets for geo-routing and multi-currency without custom edge code; Markets handles currency, language, and domain routing natively
WooCommerce Add Cloudflare as your CDN/proxy to get edge capabilities Cloudflare Workers (free tier: 100k requests/day) adds edge logic; configure in Cloudflare dashboard after adding your domain
BigCommerce BigCommerce uses Fastly CDN globally Use BigCommerce's built-in multi-storefront feature for geo-routing; for custom edge logic add Cloudflare in front
Custom / Headless Full control — choose Cloudflare Workers, Vercel Edge Middleware, or Fastly Compute Build custom geo-routing, A/B testing, and personalization at the edge; see implementation below

Step 2: Configure geo-routing on your platform


Shopify: Use Shopify Markets

  1. Go to Settings → Markets in your Shopify admin
  2. Click Add market and select the countries/regions for your new market
  3. Configure per-market settings:
    • Currency: set the local currency (Shopify handles conversion automatically)
    • Language: assign a translated theme version
    • Domain/subdomain: e.g., uk.yourstore.com routes UK visitors automatically
  4. Shopify automatically redirects users to their market based on IP geolocation — no custom code needed
  5. For manual market URL overrides: Shopify's cookie-based market selector handles users who want to change their market

WooCommerce: Cloudflare Workers geo-routing

  1. Add your domain to Cloudflare (free plan is sufficient for geo-routing)
  2. Go to Workers & Pages → Create Worker in the Cloudflare dashboard
  3. Add a simple geo-redirect rule:
// Cloudflare Worker — deploy via Cloudflare dashboard
export default {
  async fetch(request) {
    const country = request.headers.get('CF-IPCountry') ?? 'US';
    const url = new URL(request.url);

    // Redirect UK users to UK store variant
    if (country === 'GB' && !url.pathname.startsWith('/uk')) {
      return Response.redirect(`https://${url.hostname}/uk${url.pathname}`, 302);
    }

    return fetch(request);
  }
};
  1. In Worker settings, add a Route that matches your domain: *yourstore.com/*
  2. For currency/language: use a WooCommerce multi-currency plugin (WPML + WooCommerce Multilingual, or Aelia Currency Switcher) that reads the URL path or a cookie set by the Worker

Custom / Headless

Vercel Edge Middleware (Next.js) for geo-routing:

// middleware.ts — runs at the edge globally, <5ms
import { NextRequest, NextResponse } from 'next/server';
import { geolocation } from '@vercel/functions';

const REGION_MAP: Record<string, string> = {
  GB: 'uk', DE: 'de', FR: 'fr', CA: 'ca', AU: 'au',
};

export function middleware(request: NextRequest) {
  const { country } = geolocation(request);
  const region = country ? REGION_MAP[country] : null;

  // Redirect root to regional store
  if (region && request.nextUrl.pathname === '/') {
    const url = request.nextUrl.clone();
    url.pathname = `/${region}`;
    return NextResponse.redirect(url, { status: 302 });
  }

  // Pass country to origin for catalog/pricing logic
  const response = NextResponse.next();
  if (country) response.headers.set('x-user-country', country);
  return response;
}

export const config = { matcher: ['/', '/products/:path*', '/collections/:path*'] };

Edge A/B testing (assign variant once, persist in cookie):

// In middleware.ts — no origin round-trip needed
const EXPERIMENTS = [
  { id: 'checkout-cta', buckets: [{ name: 'control', weight: 0.5 }, { name: 'variant-a', weight: 0.5 }] },
];

function assignVariant(buckets: Array<{name: string; weight: number}>) {
  let r = Math.random(), cumulative = 0;
  for (const b of buckets) {
    cumulative += b.weight;
    if (r < cumulative)
Full SKILL.md on GitHub

Install edge-commerce in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

claude-code
cursor
gemini-cli
copilot
codex-cli
kiro
opencode

Bundled files

evals/cloudflare-workers-kv-caching-regional-p/criteria.jsonevals/cloudflare-workers-kv-caching-regional-p/task.mdevals/edge-personalization-with-shell-caching-/criteria.jsonevals/edge-personalization-with-shell-caching-/task.mdevals/vercel-edge-middleware-geo-routing-and-a/criteria.jsonevals/vercel-edge-middleware-geo-routing-and-a/task.mdtile.json

FAQ

What does the edge-commerce skill do?

Reduce latency globally by running geo-routing, A/B tests, and personalization logic at the network edge using Cloudflare Workers or Vercel

How do I install the edge-commerce skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the edge-commerce skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare edge-commerce with