A better-auth plugin that enriches authentication sessions with Vercel edge geolocation data. Version 1.2.0 adds timezone support. Released as an MIT-licensed open source project with community-driven updates. Unlike manual IP geolocation, it reads Vercel's request headers (x-vercel-ip-*) server-side without external APIs or browser prompts. Requires Vercel deployment and better-auth >=1.4.18 (peer dependency ^1.5.0). Configurable fields include city, country, region, latitude, longitude, postal code, timezone, and a derived flag emoji. Ships TypeScript types and offers both server and client plugins.
npm install better-auth-vercel-geolocationVerified import paths — ran on the pinned version, not inferred.
Demonstrates server plugin setup with optional field config, client plugin initialization, and accessing geolocation fields from the session object in a React component.
Uninstall any old version and install better-auth-vercel-geolocation@1.0.0 or later.
Use Vercel preview deployments or local Vercel CLI (`vercel dev`) to test geolocation data.
Ensure better-auth is updated: `npm install better-auth@^1.5.0`
If you need reliable region/flag, compute them client-side from city/country.
Only import `geolocationClient` from `better-auth-vercel-geolocation/client` and pass it to the client.
Ensure your package.json has `"module": "ESNext"` or configure TypeScript `moduleResolution` to `bundler` or `node16`. Or use full path: `import { geolocationClient } from 'better-auth-vercel-geolocation/client'`Check that plugin is added to both server and client. On localhost, fields will be undefined; use optional chaining: `session?.city`
Run `npm install better-auth@^1.5.0` or update your package.json.