gistda-sphere-react

useSphere

Access the Sphere API namespace without requiring a map

Access the Sphere API namespace without requiring a map.

import { useSphere } from 'gistda-sphere-react';

function SphereInfo() {
  const { sphere, isLoaded, error, apiKey } = useSphere();

  if (!isLoaded) return <div>Loading API...</div>;
  if (error) return <div>Error: {error.message}</div>;

  return <div>API loaded with key: {apiKey}</div>;
}

Return value

PropertyTypeDescription
sphereSphereNamespace | nullThe global sphere API namespace
isLoadedbooleantrue when the API script has loaded
errorError | nullError if the API failed to load
apiKeystringThe API key passed to SphereProvider

On this page