@solid-primitives/geolocation

Primitives to query geolocation and observe changes.

Usage no npm install needed!

<script type="module">
  import solidPrimitivesGeolocation from 'https://cdn.skypack.dev/@solid-primitives/geolocation';
</script>

README

@solid-primitives/geolocation

lerna size size stage

Primitives to query and watch geolocation information from within the browser.

Installation

npm install @solid-primitives/geolocation
# or
yarn add @solid-primitives/geolocation

How to use it

createGeolocation

Used to fetch current geolocation data as a resource.

const [location, refetch] = createGeolocation();

or with options:

const [location, refetch] = createGeolocation({
  enableHighAccuracy: false,
  maximumAge: 0,
  timeout: 200
});

createGeolocationWatcher

Creates a geolocation watcher and updates a signal with the latest coordinates.

const [location, error] = createGeolocationWatcher(true);

Demo

You may view a working example here: https://codesandbox.io/s/solid-primitives-geolocation-fhzu4?file=/src/index.tsx

Changelog

Expand Changelog

0.0.100

Pulling an early release of the package together and preparing for 1.0.0 release. No changes.

1.0.0

Added testing, improved types, changed name of createGeolocationWatcher to createGeolocationMonitor.

1.0.6

Published with CJS and SSR support.

1.0.7

Changed to peerDependencies and updated to latest Solid