HatchedDocs
Reference

SDK (React Native)

Component and hook reference for @hatched/react-native — HatchedProvider, the native widgets, HatchedWebView, and hooks.

Package: @hatched/react-native

npx expo install @hatched/react-native
# optional peers
npx expo install react-native-webview react-native-svg

For the end-to-end walkthrough (tokens, theming, WebView fallback, pitfalls) see React Native integration. This page is the API surface.

<HatchedProvider>

Owns the shared data layer and must wrap every widget and hook.

PropTypeRequiredNotes
tokenstringyesWidget session token or read-only embed token (server-minted).
apiBaseUrlstringyese.g. https://api.hatched.live/api/v1.
theme'light' | 'dark'noInitial mode; the live /widget/theme palette/personality overrides it.
langstringnoUI language hint (defaults to English).
pollIntervalMsnumbernoBase /widget/state poll interval.
onCelebrate(event) => voidnoFired on badge / evolution / streak celebrations.

The provider polls /widget/state, pauses while the app is backgrounded (AppState), honors the OS reduced-motion setting, and re-resolves the theme on foreground.

Widgets

All widgets accept an optional style prop and must render inside <HatchedProvider>.

ComponentPropsSurface
BuddyWidgetallowRadar?: booleanBuddy image, name, coins, skills (bars or SVG radar), badge/rank counters, evolution-ready hint.
LeaderboardWidgetscope?: 'global' | 'team', viewMode?: 'top' | 'around_me' | 'hybrid', limit?: numberRanked board with the current player highlighted.
MarketplaceWidgetBrowse, buy, equip. CTAs are scope-gated.
StreakWidgetstreakKey?: stringCurrent streak, best, next milestone.
BadgesWidgetEarned badges + earned/total counter.
TokensWidgetPrimary balance + capped progression tokens.
PathWidgetpathKey?: stringJourney steps/sub-steps; tappable optimistic completion.

StreakWidget, PathWidget, and LeaderboardWidget fetch their own endpoint; the rest read state hydrated by the provider's /widget/state poll.

<HatchedWebView>

Renders a Hatched widget through the production CDN loader for the surfaces not reimplemented natively.

PropTypeNotes
widgetstringOne of kudos, group-quest, feed, mystery-box, league, council, hexad-survey, celebrate. Required.
tokenstringFalls back to the provider.
apiBaseUrlstringFalls back to the provider.
theme'light' | 'dark'Falls back to the provider's mode, else light.
cdnBaseUrlstringLoader origin; defaults to https://cdn.hatched.live.
onEvent(name, payload?) => voidready / effects from the bridge.
onCelebrate(event) => voidCelebration events from the widget.
syncStorebooleanForward track effects into the provider's store (default true).

Requires the react-native-webview peer. The token is injected after load (never in the HTML); the loader's bridge forwards effects/celebrations back to the shared store.

Hooks

HookReturns
useTrack()(type: string, properties?: Record<string, unknown>) => Promise<TrackResult | null>
useHatched(){ store, token, apiBaseUrl, ready, track, refresh }
useTheme()the resolved ResolvedTheme
useWorkspaceState()the full WorkspaceState (re-renders on change)
useWorkspaceStore(selector)selector(WorkspaceState), re-rendered on change

Optional peers

PeerNeeded forWithout it
react-native-webview<HatchedWebView>Mounting it throws a clear install error.
react-native-svgBuddy skill radarBuddy widget falls back to skill bars.
@react-native-async-storage/async-storagePersisting ceremony-seen stateFalls back to in-memory.

@hatched/widget-core

@hatched/react-native builds on @hatched/widget-core — the headless, render-free core (workspace store, smart-poll, fetch/auth, theme resolution, shared types) that also powers the web widgets. You normally consume it transitively; install it directly only if you build a custom renderer. The commonly needed types (ResolvedTheme, WorkspaceState, BuddyData, TokensPayload, …) are re-exported from @hatched/react-native.