I\'m using firebase I\'m thinking the way how to do this.
You're on the right track. But there is no API to find the nearest user.
There is however an add-on library called GeoFire that allows you to find all keys within a certain range. It does this by encoding the user location in a so-called geohash, which it then allows you to query.
With this you could: