@joinbankroll/sdk/react is the client-side glue that behaves identically in
every app: reading host status without flashing the wrong screen through
hydration, a fetch that carries the session token, and a development overlay.
Your app’s own product surface stays in your app.
react is an optional peer (>= 18), installed only if you use this entry.
Host status
useBankrollStatus() is bankroll.status()
as a hook. The host is injected before your page loads and never changes
afterwards, so there is nothing to subscribe to — the work these do is agreeing
across the hydration boundary.
useBankrollChecked() is why the pair exists. It is false during the server
render and the first client paint, and true after. Render a loading state on
it rather than deciding, or a phone already inside Bankroll sees “get the
Bankroll app” until hydration corrects it. Server and client deliberately agree
on 'unavailable' for the same reason: the wrong screen briefly is worse than
no screen briefly.
Fetch with the session token
withBankrollToken(fetch), already
built and bound. Binding matters — fetch throws when called detached from the
window — and on the server it resolves to the bare global, so importing this
module never crashes a render that doesn’t use it. In a plain browser the
request goes out bare and your server answers 401.
Sending a user through verification
session({ identity: true }) reduced to the question a UI actually asks:
true once the user is verified, false if they declined or the host refused.
Anything that is not a host rejection propagates. Use it for an explicit “verify
to continue” button; for gating a paid action, check
session.user.identity on your server,
which is the only place the answer is trustworthy.
Development overlay
ok: false render in amber, and copy: true truncates the display while
putting the full value on the clipboard, since a shortened address you can’t
copy is useless.
In a Next.js app the overlay also hides Next’s own dev badge, which otherwise
stacks with it in a phone-sized viewport, and offers it back behind a toggle.