Overview
IP geolocation enriches session and event data with:- Country and country code
- City
- Region/state
- Timezone information (provider-dependent)
Configuration
Configure IP geolocation in yourstudio.config.ts:
studio.config.ts
Providers
IPInfo.io
IPInfo.io offers both free and paid tiers with different endpoints.Free Tier (Lite)
Thelite endpoint provides country and continent data only:
Paid Tier (Lookup)
Thelookup endpoint provides city, region, and full location data:
Set to
"ipinfo" for IPInfo.io"lite": Free tier - country/continent only"lookup": Core/Plus tier - city/region data
"lookup"Custom base URL for IPInfo.io APIDefault:
"https://api.ipinfo.io"IPApi.co
IPApi.co provides free and paid IP geolocation services:studio.config.ts
Set to
"ipapi" for IPApi.coYour IPApi.co API token (optional for free tier with rate limits)
Custom base URL for IPApi.co APIDefault:
"https://ipapi.co"Static (MaxMind GeoLite2)
Use a local MaxMind GeoLite2 database file for offline IP resolution:studio.config.ts
Set to
"static" for MaxMind local databaseAbsolute or relative path to the
.mmdb fileExample: "./data/GeoLite2-City.mmdb"Download GeoLite2 database files from MaxMind. You’ll need to create a free account.
TypeScript Type Definition
Fallback Behavior
When IP geolocation is configured, Studio attempts resolution in this order:- Configured provider (ipinfo or ipapi)
- Local MaxMind database (if available at
./data/GeoLite2-City.mmdb) - Default geo database (built-in JSON database)
- Hardcoded IP ranges (basic country detection)
If the configured provider fails (network error, invalid token, rate limit), Studio automatically falls back to local databases to ensure the UI remains functional.
Environment Variables
Store API tokens in environment variables:.env
studio.config.ts
Usage in Studio
Once configured, IP geolocation data appears in:Sessions Page
View session locations with:- Country flag
- City, Region
- Country name
- IP address
Events Page
See where authentication events occurred:- Event type (login, signup, etc.)
- User information
- Geographic location
- Timestamp
Performance Considerations
Optimization Tips
- Use static provider for high-volume applications
- Cache results (Studio handles this internally)
- Choose appropriate tier based on your traffic
- Monitor usage to avoid rate limit errors
Example Configurations
Development (Free)
studio.config.ts
Production (Paid)
studio.config.ts
Self-Hosted (MaxMind)
studio.config.ts
Troubleshooting
No Location Data Showing
- Verify your API token is valid
- Check for rate limit errors in server logs
- Ensure the provider endpoint is correct
- Test the API token with a direct request
Invalid IP Addresses
- Localhost IPs (127.0.0.1, ::1) cannot be resolved
- Private network IPs (192.168.x.x, 10.x.x.x) are not supported
- Ensure your application captures real client IPs
MaxMind Database Issues
- Verify the
.mmdbfile path is correct - Ensure the file is not corrupted
- Download the latest version from MaxMind
- Check file permissions