easiest way to get user location from ip in nextjs?
Answered
Havana posted this in #help-forum
HavanaOP
without using the browser native api, what do you think the best solution would be? Is it possible to get the ip easily from nextjs and query some third party api to get the approximate location? If yes, which one do you suggest?
Answered by gin
u can also read the raw ip from the headers and use apis like https://ip-api.com/
to get the geolcation
to get the geolcation
9 Replies
@Havana without using the browser native api, what do you think the best solution would be? Is it possible to get the ip easily from nextjs and query some third party api to get the approximate location? If yes, which one do you suggest?
not directly from nextjs but from vercel u can (if u host on vercel)
Cloudflare does the same ->
https://developers.cloudflare.com/network/ip-geolocation/
https://developers.cloudflare.com/network/ip-geolocation/
u can also read the raw ip from the headers and use apis like https://ip-api.com/
to get the geolcation
to get the geolcation
Answer
be aware of ratelimits tho
HavanaOP
mm gotcha, thank you very much