Overview
Thelocation context is available on every AgentExecutionContext and provides:
- Geographic data: Country, city, region, coordinates, timezone
- Jurisdiction detection: GDPR, CCPA, LGPD, and other privacy laws
- Consent helpers: Check if consent is required for specific purposes
- Language inference: Detect preferred language from headers or country
- Timezone utilities: Format times, check business hours
Geographic Data
Access location information extracted from Cloudflare’s edge:Region Checking
UseisIn() to check if the user is in specific regions or groups:
Available Region Groups
| Group | Countries |
|---|---|
EU | 27 EU member states |
EEA | EU + Iceland, Liechtenstein, Norway |
GDPR | EEA + UK |
APAC | Asia-Pacific (CN, JP, KR, SG, AU, IN, etc.) |
LATAM | Latin America (BR, MX, AR, CL, etc.) |
MENA | Middle East & North Africa |
NORTH_AMERICA | US, CA, MX |
ASEAN | Southeast Asian nations |
FIVE_EYES | US, GB, CA, AU, NZ |
NINE_EYES | Five Eyes + DK, FR, NL, NO |
FOURTEEN_EYES | Nine Eyes + DE, BE, IT, SE, ES |
G7 | US, GB, CA, FR, DE, IT, JP |
G20 | Major economies |
BRICS | BR, RU, IN, CN, ZA |
MERCOSUR | BR, AR, UY, PY |
Jurisdiction Detection
Automatically detect which privacy laws apply to the user:Supported Jurisdictions
| Jurisdiction | Region | Model |
|---|---|---|
GDPR | EU + EEA + UK | Opt-in |
CCPA | California, USA | Opt-out |
LGPD | Brazil | Opt-in |
PIPEDA | Canada | Opt-in |
POPIA | South Africa | Opt-in |
PDPA | Singapore | Opt-in |
APPI | Japan | Opt-in |
Consent Helpers
Check if consent is required before processing user data:Consent Purposes
| Purpose | Description | GDPR | CCPA |
|---|---|---|---|
essential | Core functionality | No consent needed | No consent needed |
analytics | Usage tracking | Requires consent | Allowed (opt-out) |
marketing | Ads, promotions | Requires consent | Allowed (opt-out) |
personalization | Recommendations | Requires consent | Allowed (opt-out) |
third_party | Partner sharing | Requires consent | Allowed (opt-out) |
Consent Model
Get the consent model to use:Consent-Aware Cookies
The cookies operation integrates directly with location context to automatically enforce consent rules. When you specify apurpose for a cookie, the operation checks if consent is required and granted before setting the cookie.
Language Inference
Detect the user’s preferred language:Language Matching Priority
- Accept-Language header - User’s browser preference
- Country’s primary language - Fallback based on location
- First supported language - Ultimate fallback
Timezone Utilities
Work with the user’s local time:Smart Scheduling
Real-World Example
A complete example showing consent gating and localization:TypeScript Types
Import types directly from the package:Next Steps
Edge Context
Network and infrastructure info
Security
Authentication and authorization
Operations
Available operation types
Creating Agents
Build custom agents

