The platform-neutral JSON transport shared by web and Expo.
statshub-api-client owns HTTP behavior that must agree across the browser,
Next.js, and React Native. It has no React, Next.js, Expo, Supabase, or Better
Auth dependency.
Adapter used by Next.js to add cache metadata and by tests to supply responses.
headers
HeadersInit
No
none
Headers applied to every request.
getHeaders
() => HeadersInit | Promise<HeadersInit>
No
none
Request-scoped cookie or bearer headers. Called for every request.
unwrapData
boolean
No
false
Returns the value inside a successful { data: value } body.
Header precedence is fixed: static client headers, then getHeaders, then the
JSON content type, then request headers. A caller can override any earlier
value for one request.
Adds Next.js revalidation tags. Private reads inject the complete Supabase cookie header and use no-store.
Web client components
Gives SWR a same-origin get or post function.
Expo
Supplies the absolute API origin. The StatsHub-specific client keeps its Cloudflare backoff and cached-5xx retry.
getHeaders is an authentication seam, not an identity provider. Web sessions
remain Supabase sessions because the Go API validates Supabase credentials.
Expo accounts remain Better Auth sessions in Convex. The two providers cannot
be exchanged until the Go API accepts the same identity; sharing a TypeScript
interface would not make their cookies or tokens compatible.