# Is there a smart way to get a users country / location without external APIs?

**URL:** <https://community.weweb.io/t/is-there-a-smart-way-to-get-a-users-country-location-without-external-apis/10304>\
**Category:** Tips and Hacks\
**Created:** [August 18, 2024, 9:01am UTC](https://community.weweb.io/t/is-there-a-smart-way-to-get-a-users-country-location-without-external-apis/10304 "2024-08-18T09:01:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaefner](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/chaefner/32/9652_2.png) [@chaefner](https://community.weweb.io/u/chaefner)\
**Post date:** [August 18, 2024, 9:01am UTC](https://community.weweb.io/t/is-there-a-smart-way-to-get-a-users-country-location-without-external-apis/10304/1 "2024-08-18T09:01:53Z")

</div>

I am creating a multi-language app with WeWeb that recommends products to users based on their country.

Example

- Language = EN | Country = US → Product 1
- Language = EN | Country = UK → Product 2

I know there are API services such as [geo.ipify.org](http://geo.ipify.org). But maybe someone found a solution that works without that?

Extra: This is only relevant for non-logged in users. As soon as a user registers with my app, the IP address can be overridden with country settings made by the user.

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 18, 2024, 9:41am UTC](https://community.weweb.io/t/is-there-a-smart-way-to-get-a-users-country-location-without-external-apis/10304/2 "2024-08-18T09:41:27Z")

</div>

You really only have two options other than using the third party APIs:

1. Ask them directly client-side for their location
2. Make your own server side endpoint with backend packages like whois, whoiser and use those

I know that Supabase for example provides really good informations about the invoker of the functions, so probably one might use it straight away (I haven’t had a usecase yet). As far as for Xano, I’m not sure. So yeah, these are the perks of Supabase over other backends, they have these little quality of life things 😃

 ![Screenshot 2024-08-18 at 11.41.04](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/f/f352561c12d3a52b6e7f7431a0ed9196d5e40fe4.png)

---

<div class="post-metadata">

**Author:** ![khara](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/khara/32/6776_2.png) [@khara](https://community.weweb.io/u/khara)\
**Post date:** [August 18, 2024, 2:07pm UTC](https://community.weweb.io/t/is-there-a-smart-way-to-get-a-users-country-location-without-external-apis/10304/3 "2024-08-18T14:07:12Z")

</div>

I use this JS for their browser language, posthog for more granular analytics info (fast install via snippet).

````auto
var userLanguage = navigator.language || navigator.userLanguage;
return userLanguage```
````

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 18, 2024, 2:09pm UTC](https://community.weweb.io/t/is-there-a-smart-way-to-get-a-users-country-location-without-external-apis/10304/4 "2024-08-18T14:09:37Z")

</div>

I have my browser in Italian but I’m living in Slovakia 😃

---

<div class="post-metadata">

**Author:** ![khara](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/khara/32/6776_2.png) [@khara](https://community.weweb.io/u/khara)\
**Post date:** [August 18, 2024, 3:09pm UTC](https://community.weweb.io/t/is-there-a-smart-way-to-get-a-users-country-location-without-external-apis/10304/5 "2024-08-18T15:09:38Z")

</div>

chaotic neutral vibes ahahha ✨✨

---

<div class="post-metadata">

**Author:** ![raydeck](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raydeck/32/384_2.png) [@raydeck](https://community.weweb.io/u/raydeck)\
**Post date:** [August 19, 2024, 10:44am UTC](https://community.weweb.io/t/is-there-a-smart-way-to-get-a-users-country-location-without-external-apis/10304/6 "2024-08-19T10:44:49Z")

</div>

Is the problem that you want to get the location of the user without having to look it up? That’s not exposed by the browser, but it is implied by the IP of the user. You solve it through a lookup. The question is how you get that translation. In addition to contracting with a third party metered service, you have other options:

Supabase and Xano both offer this as a freebie AFAICT.

You can also download a free table of ranges and countries to roll it yourself on the frontend or backend. Here’s one repo with this data: [GitHub - sapics/ip-location-db: ip to location database by ASN, GeoFeed, Whois, iptoasn.com, db-ip lite, GeoLite2](https://github.com/sapics/ip-location-db)
