We’re excited to announce an update to Cloudflare Workers, our serverless code platform built on our global network. Geolocation data is now accessible and free for all developers on our Workers platform, including users on the free plan!
You can now serve personalized experiences for users based on their location using Workers. Personalization is critical to building intuitive apps for users and it unlocks new possibilities for what you can build on our platform. Whether you’re building a social networking app or an automatic shipping cost estimator for an e-commerce site, a one-size-fits-all experience doesn’t cut it. Location-based personalization helps you show what’s most relevant to your users, be it tickets for movies in their area or content in their local language.
With geolocation data available on the server side, there’s no configuration needed for users to set their location.
Each request to a Worker includes the user’s (example data shown):
- Country: “US”
- City: “Austin”
- Continent: “NA”
- Latitude: "30.27130"
- Longitude: “-97.74260”
- Postal code: "78701"
- Metro code(dma): “635”
- Region: “Texas”
- Timezone: “America/Chicago”
Geolocation data on Workers makes it even easier to build server rendered apps and customized services.
Refer to the documentation to learn more.
In case you need some inspiration on how you can use this data, here are some quick and fun examples to get you started:
Personalized UI Design
This is a Worker that customizes the user interface based on the user’s local time. The background changes throughout the day showing blue gradients during daylight and darker gradients at night. It’d be interesting to implement automatic dark mode for apps on Workers using a similar approach as well.
Location Based Applications
This is a Worker reporting the air quality near your location using the World Air Quality Project’s API. For other ideas, you could build a simple analytics service or a review platform for local businesses.
These are just some examples of what you can make using geolocation. We are excited to see what you build and we’d love to hear from you in our Workers Discord.