Documentation
Polyfence documentation
Polyfence is a geofence layer: you define a zone once, and the same zone is evaluated on your mobile app, on your own hardware, and on your server — four separate implementations of the same rules.
Install an SDK, define a zone, start getting events. Each runtime’s own README carries its setup and configuration; everything else is below.
Start
Two ways in.
Paste this into Claude Code, Cursor or Codex:
Add Polyfence to this project. Install the SDK for the framework you find here, follow its README for platform setup, then define one zone and log its enter and exit events.
Pick your runtime below, run its install line, and follow its README.
Managing zones from a terminal instead? npm i -g polyfence-cli
Neither needs an API key to start — zones you write in code are evaluated on the device, and nothing leaves it. A key is for when you want zones to arrive from us, or events to reach your account. Create an API key →
Quickstart
Quickstart
Pick your platform below: install, add a zone, start detecting.
Each SDK’s README carries the full install, platform setup, configuration and background-reliability detail for that runtime — Flutter, React Native, core (Kotlin/Swift), embedded C. All MIT.
import 'package:polyfence/polyfence.dart';
await Polyfence.instance.initialize();
await Polyfence.instance.requestPermissions();
await Polyfence.instance.addZone(Zone.circle(
id: 'depot-north',
name: 'Depot North',
center: PolyfenceLocation(latitude: 51.95724, longitude: 1.30962),
radius: 230,
));
Polyfence.instance.onZoneEnter.listen((event) {
print('Entered: ${event.zoneName}');
});
await Polyfence.instance.startTracking();
Runtimes
Pick your runtime
Each README carries that runtime’s minimum version, platform setup and configuration.
On a phone
Flutter and React Native are wrappers around the Kotlin and Swift engines listed below them. Choosing one doesn’t add a second implementation to trust — it’s the same code underneath, called a different way.
On your own hardware
On your server
Every runtime runs the same algorithms against the same constants, and the C library has been tested against this server and against itself on two CPU architectures. No test compares a phone’s event stream to either. If Kotlin or Swift drifted, nothing in the suite would currently catch it — both runs, and what they cover →
Scope
What Polyfence does not do
Deliberately, and with no plan to change: these are the parts of a location product only you can write.
device_id. Who that is lives in your database, never in ours.Guides
The things that bite
Each of these is a section inside a README, written next to the code it describes.
pf_load_zones() silently drops.The algorithmsHaversine and ray-casting, written once and ported three times.Reference
API reference
GET /v1/events — cursor-paginated, newest first. The loop is yours to write and schedule.429 means slow down: it carries Retry-After and an X-RateLimit-Limit header with your per-second ceiling. 403 means this key is not allowed to do that.Ready to start building?
Create your first zone and start integrating Polyfence.
Free during Early Access. No credit card.