Tracking user locations based on IP addresses is a frequent requirement for security auditing, fraud detection, and creating localized customer experiences inside Salesforce. While legacy systems relied heavily on Visualforce, modern Salesforce architecture dictates using Lightning Web Components (LWC) backed by an Apex REST callout to fetch and display this geographic data securely. In plain words: An LWC captures the IP address input by the user and passes it to an Apex class. The Apex class sends an HTTP request to an external geolocation API, receives a JSON package containing location details (like city, country, and time zone), parses it, and sends it back to the LWC to be displayed on the screen.
Lightning Web Components