upwell/react
UpwellProvider, useAppUpdate, useUpdateHistory, useUpwell and useUpwellState.
import { UpwellProvider, useAppUpdate, useUpdateHistory, useUpwell, useUpwellState } from 'upwell/react';UpwellProvider
Owns an UpwellController and runs the launch and foreground checks.
<UpwellProvider
policy="https://cdn.example.com/upwell/policy.json"
releases="https://cdn.example.com/upwell/releases.json"
ota={expoUpdatesAdapter()}
debug={__DEV__}
>
<App />
</UpwellProvider>It accepts every UpwellOptions field, including
onDecision, onError and onEvent, plus:
Prop
Type
Options are read once, when the provider mounts. To change them later, create a controller
with createUpwell() and pass it as controller. The same goes for callbacks: an inline
onEvent keeps the values it closed over on the first render, so call module-level clients
(posthog.capture) or read the latest values through a ref.
Sending events to your analytics
<UpwellProvider
ota={expoUpdatesAdapter()}
onEvent={(event) => {
if (!event.simulation) posthog.capture(`upwell_${event.type}`, event);
}}
>
<App />
</UpwellProvider>onEvent works the same with or without the UI kit; useAppUpdate() doesn't change. See
Send update events to your analytics.
useAppUpdate
What kind of update this user needs, and the actions to drive it.
const { decision, progress, isRequired, startUpdate, dismiss } = useAppUpdate();Prop
Type
startUpdate() and startStoreUpdate() resolve to a flow result
for store flows.
useUpdateHistory
OTA release notes from releases.json.
const { current, history, justUpdated, markSeen } = useUpdateHistory();Prop
Type
useUpwellState
The full UpwellState. Re-renders on every change.
const { installed, policy, policyWarnings, trace } = useUpwellState();useUpwell
The controller from the nearest provider. Throws outside one.
const upwell = useUpwell();
await upwell.check({ force: true });