Determine your User Location with Netlify Edge Functions
Blog post from Nx
Using @nx/netlify serverless functions to determine a user's location can enhance various applications by customizing user experiences, displaying localized content, or tracking demographics. The guide outlines a step-by-step process starting with setting up an Nx workspace, creating a serverless function, and determining the user's location using the IP address from the request headers. An IP geolocation API like ipapi is used to fetch location data, and Node.js 18's global fetch API or node-fetch for earlier versions handles API requests. Deployment involves creating a site on Netlify, initializing it, and running a deploy command, after which the user-location function becomes accessible in the Netlify Functions tab, providing location details such as city, region, and country.