Skip to main content
import { useSunbreak } from '@tdfc/sunbreak-svelte';

const ctx = useSunbreak();
Must be called inside a component that is a descendant of <SunbreakProvider>.

Shape

{
  get<T>(path: string, opts?: RequestInit): Promise<T | undefined>;
  post<T>(path: string, body?: unknown, opts?: RequestInit): Promise<T | undefined>;
  session(): Promise<SessionResp | undefined>;
  refresh(): Promise<boolean>;
  authenticated: boolean;
  loading: boolean;
  error: string | null;
  allowed: boolean | null;
  sessionExpiry: number | null;
  sessionData: SessionResp | null;
  wallet: string | null;
}
The shape is identical to the React useSunbreak hook.
Do not destructure. State properties use Svelte getters for reactivity. Destructuring captures the value once and will not update.