@dakota-xyz/cards-js— the framework-free core.@dakota-xyz/cards-js/react— the React binding. It needsreact >= 18.@dakota-xyz/cards-js/styles.css— the default stylesheet.
@dakota-xyz/cards-js (core)
class DakotaCards
The client. Create one per app and reuse it.
class CardDetailsHandle
Controls one card. Get it from cards.cardDetails(...) — you do not construct it yourself.
Events
CardDetailsEvents maps each event name to its payload.
Errors are not delivered as events.
mount() and reveal() reject with a DakotaCardsError, so handle them with try/catch. cardDetails() throws invalid_theme synchronously when a theme value is not concrete, and mask() throws invalid_state synchronously on a destroyed handle.Sessions
Errors
Theming & strings types
@dakota-xyz/cards-js/react
The React entry point re-exports DakotaCards, CardDetailsHandle, and the card types its own signatures use, as types only. Construct the client with new DakotaCards(...) imported from the core entry point, as in the React quickstart on the overview. Import FetchSession, the error types, and the theming types from the core entry point too.
<DakotaCardsProvider>
Supplies a DakotaCards client to the component tree.
useDakotaCards()
Error (not a DakotaCardsError) if it is used outside one.
<CardDetails> and useCardDetails
<CardDetails> renders the .dk-card recipe and exposes reveal and mask through a ref.
<CardDetails> always renders all four value slots and their captions from the .dk-card recipe. fields only selects which of those slots the SDK binds — mounts the masked face into, and reveals. Slots you omit still render, as empty captioned placeholders. To render a genuinely partial layout, with fewer slots on the page, use the headless useCardDetails hook and lay out only the fields you want.
useCardDetails is the headless form: you render the recipe yourself and wire the refs.
reveal rejects with a plain Error (not a DakotaCardsError) when the card is not mounted.
Both <CardDetails> and useCardDetails build their handle once per client, from the options of the first render. Later changes to last4, theme, autoMaskMs, strings, or fields are ignored; remount with a new key to apply them. A fetchSession passed on the first render is always called in its latest form. One added only on a later render is ignored, and the client-level one is used instead.
When you render your own markup, some CSS rules are load-bearing. See Custom markup.
