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

webxr-geospatial

v0.1.0

Published

TypeScript utilities for geospatial positioning in WebXR applications

Downloads

133

Readme

webxr-geospatial

Dependency-free TypeScript utilities for manually fetching local geospatial data inside WebXR applications.

The package reads from a local API on the same device as the WebXR app:

http://127.0.0.1:8765/location

It does not poll automatically. Trigger a fetch when your app needs a fresh geospatial override, for example from a button.

Install

npm install webxr-geospatial

Fetch a location

import { fetchGeospatialLocation } from "webxr-geospatial";

const result = await fetchGeospatialLocation();

if (result.available) {
  console.log(result.latitude, result.longitude, result.altitude);
} else {
  console.warn(result.message);
}

Select specific fields

Without fields, the full API payload is returned. With fields, only the selected location fields are included.

const result = await fetchGeospatialLocation({
  fields: ["latitude", "longitude", "altitude"]
});

if (result.available) {
  console.log(result.latitude, result.longitude, result.altitude);
}

Available fields:

type GeospatialLocationField =
  | "latitude"
  | "longitude"
  | "altitude"
  | "heading"
  | "horizontalAccuracy"
  | "verticalAccuracy"
  | "headingAccuracy"
  | "timestampMs";

Button-triggered WebXR usage

Use the provider when your app wants to refresh the override manually and read the latest fetched value elsewhere in the WebXR flow.

import { createGeospatialLocationProvider } from "webxr-geospatial";

const provider = createGeospatialLocationProvider();
const button = document.querySelector<HTMLButtonElement>("#refresh-location");

button?.addEventListener("click", async () => {
  const result = await provider.refresh({
    fields: ["latitude", "longitude", "altitude", "heading", "timestampMs"]
  });

  if (!result.available) {
    console.warn(result.message);
  }
});

function updateWebXRScene() {
  const location = provider.getLocation();

  if (location?.available) {
    // Use this location as the app's geospatial override.
    console.log(location.latitude, location.longitude, location.altitude);
  }
}

Configuration

await fetchGeospatialLocation({
  baseUrl: "http://127.0.0.1:8765",
  timeoutMs: 5000,
  signal: abortController.signal
});

baseUrl may point either to the local server root or directly to /location.

Result shape

Successful responses are flat and mirror the local API:

{
  available: true,
  latitude: 52.47,
  longitude: 13.29,
  altitude: 83.4,
  heading: 120.5,
  horizontalAccuracy: 1.8,
  verticalAccuracy: 2.4,
  headingAccuracy: 4.2,
  timestampMs: 1781773200000
}

Unavailable or failed requests return a typed unavailable result:

{
  available: false,
  message: "Noch keine Geospatial-Position verfügbar.",
  errorCode: "unavailable"
}