npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sanely/request

v0.1.0

Published

Read the client IP address and location from a request

Readme

@sanely/request reads what the network and the hosting platform report about a request: the client's IP address and, on platforms that send it, the client's location.

Features

  • Headers a client cannot forge. Name the platform the app runs on, such as Vercel, Cloudflare, or Fly.io, and ip reads only the headers that platform sets.
  • Location. geo reads the country, city, and other fields that the platform reports.
  • Your own proxies. List their addresses with parseProxies, and ip skips them.
  • No platform. With platform: "none", ip reads the connection and falls back to common forwarding headers such as X-Forwarded-For.
  • Any request. Both functions accept a Fetch Request or a Node.js-style request.
  • No external dependencies.

Install

npm install @sanely/request

The package needs Node.js 20 or later.

Get started

import { geo, ip } from "@sanely/request"

const options = { platform: "vercel" } as const

ip(request, options) // "8.8.8.8"
geo(request, options).country // "US"

Set platform to the platform the app runs on. ip then reads only that platform's headers, which a client cannot forge. With platform: "none", ip reads the connection and falls back to the common forwarding headers, such as X-Forwarded-For, which a client can forge unless a proxy in front of the app replaces them.

Behind your own proxies or load balancers, list their addresses so that ip skips them. Parse the list once at startup, so a bad entry fails before the app serves a request:

import { ip, parseProxies } from "@sanely/request"

const proxies = parseProxies(["10.0.0.0/8", "198.51.100.7"])

ip(request, { platform: "none", proxies })

Documentation

  • Reference: ip, parseProxies, geo, platforms, and types

Contributing

Read the architecture, testing guide, and root contributor guide before changing the package.

License

MIT. See LICENSE.