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

gps-now

v1.0.4

Published

A lightweight geolocation utility to return latitude and longitude even when offline using the device’s GPS.

Readme

gps-now

A lightweight geolocation utility to return latitude and longitude even when offline using the device’s GPS.

✨ Features

✅ Offline Support Works without internet by using device GPS when available (e.g., mobile, hybrid apps).

📍 Get Accurate Coordinates Quickly retrieves latitude and longitude using the browser’s or device’s built-in geolocation.

⚡ Promise-Based API Clean and modern API using async/await or .then() chains.

🌐 Cross-Platform Compatible Works in all modern browsers and hybrid mobile environments like Capacitor, Cordova, React Native WebView, etc.

🧩 Tiny & Dependency-Free Lightweight utility with zero external dependencies.

🔒 Respects User Privacy Only requests location access when invoked and doesn’t store any data.

🛠️ TypeScript Support Fully typed for great developer experience and autocompletion.

⚙️ Customizable Accuracy Settings Configure enableHighAccuracy, timeout, and maximumAge as needed.

🚀 Installation

npm install gps-now

or

yarn add gps-now

📌 Usage

import { getCurrentLocation } from "gps-now";

getCurrentLocation()
  .then(({ latitude, longitude }) => {
    console.log(latitude, longitude);
  })
  .catch(console.error);

🌐 Compatibility

Works in browsers and hybrid mobile apps.

Requires permission from the user.

No internet needed — relies on GPS.

⚙️ How It Works

This package uses the HTML5 Geolocation API to fetch the user's current coordinates.

Behind the Scenes: When you call getCurrentLocation(), it checks if geolocation is supported in the environment.

If supported, it prompts the user for location permission.

Once granted, it uses GPS or device-based location to fetch accurate latitude and longitude.

If GPS is available (e.g., on mobile), it can return location even when offline.

✅ Best used in mobile browsers or hybrid apps (Capacitor, Cordova, etc.) for offline GPS functionality.

❓ FAQ

📌 Does this work offline? Yes, as long as the device supports GPS (e.g., smartphones), it can return coordinates without an internet connection. Desktop browsers may require a network connection for geolocation.

📌 Does this store or track any location data? No. The package does not store, send, or track any data. It only retrieves your coordinates upon request.

📌 What if the user denies location permission? The promise will reject with an error. You should handle this in your app like:

getCurrentLocation().catch(err => alert("Location permission denied.")); 📌 Is it safe to use in production? Yes. It uses native browser APIs, has no external dependencies, and works in secure HTTPS environments.

📌 What browsers and environments are supported? ✅ Chrome ✅ Firefox ✅ Safari ✅ Edge ✅ Mobile Web Browsers ✅ Hybrid apps (Capacitor/Cordova) 🚫 Not supported in insecure (non-HTTPS) web pages

👨‍💻 Author

Made with ❤️ by rajasekar-arch [email protected]