hayley-ssg-template

A minimal Dioxus 0.7 starter with SSG + mise + Tailwind.

Geolocation

Browser location via dioxus_sdk_geolocation — one-shot and live-watch patterns, both gated on button clicks. Each fix also updates the Browser geolocation slot in the shared store.

Geolocation demo uses the shared location store. Coordinates come from whichever provider is active (see Manage location).

No active location yet — open Manage location and refresh a provider.

SSG & hydration

Build / SSG: The server target has no geolocation API; init_geolocator stores Err(Unsupported) but this page does not print that in HTML — idle placeholders are static so hydration matches.

Browser: Neither one-shot nor watch runs until you click. Do not call geolocation in use_effect on mount unless you intentionally want a prompt during hydration.

Applies to the next one-shot request or when you Start watching (stop an active watch first to change mode mid-session).

One-shot fix (user gesture)

Calls getCurrentPosition on WASM (same underlying API as Geolocator::get_coordinates) and prints coords.accuracy — the SDK struct omits that field.

No location yet. Click Get my location — your browser should ask for permission.

Live updates (user gesture, opt-in)

Uses watchPosition with the same metadata as one-shot. Start only when you need updates; Stop calls clearWatch.

Watch is off — no background location polling. Click Start watching when you expect to move.

Tips

  • coords.accuracy is the estimated horizontal error radius in metres (from the browser fix), not confirmation that enableHighAccuracy was honoured. Store the requested flag on each request (this demo does).
  • dioxus-sdk-geolocation Geocoordinates only has lat/lon — use position_api in this file or extend the SDK to read accuracy / altitude.
  • dioxus-sdk-geolocation listen does not expose the browser watch id; position_api::stop_watch uses clearWatch.
  • HTTPS (or localhost) is required for geolocation in most browsers.

Built with Dioxus. Static output goes to target/dx/<app>/release/web/public/.