KeyWayProvider

Wrap the part of the React tree that uses KeyWay.
appName
string
default:"CKB KeyWay"
Name displayed in the embedded login UI. Limited to 64 characters.
theme
"light" | "dark"
default:"light"
Appearance of KeyWay’s login and funding confirmation modals.
autoConnect
boolean
default:"true"
Recover the wallet and start Fiber automatically after authentication.
confirmFunding
ConfirmFunding
Optional callback for approving the validated on-chain channel funding transaction. Return true to continue to Lit-authorized signing or false to abort. When omitted, KeyWay renders its styled built-in confirmation modal.
onError
(error: Error) => void
Receives connection and device-lease failures.

useKeyWay()

FieldTypePurpose
readybooleanStored session validation has finished.
authenticatedbooleanThe user has a valid KeyWay session.
user{ id: string }Stable authenticated user identity.
connectionConnectedKeyWay | undefinedRecovered wallet and running Fiber client.
statusKeyWayStatusidle, authenticating, connecting, connected, disconnecting, or error.
errorError | undefinedLatest provider connection error.
login()() => voidOpen the email OTP modal.
logout()() => Promise<void>Stop Fiber, clear the session, and log out.
connect()() => Promise<ConnectedKeyWay>Recover and start KeyWay manually.
disconnect()() => Promise<void>Stop Fiber without logging out.

connection

Use connection.wallet.ckbAddress for the recovered address and connection.keyway for Fiber operations.
MethodPurpose
getCkbBalance()Read indexed on-chain capacity in shannons.
activateCkbChannel(amount, onProgress?)Connect a channel peer and fund a public CKB channel.
waitForChannelReady(channelId, options?)Wait until a funding transaction becomes a usable channel.
listChannels(options)Read channels, state, local balance, and remote balance.
newInvoice(params)Create a Fiber invoice.
parseInvoice(params)Decode and validate an invoice before payment.
sendPayment(params)Start a routed Fiber payment.
waitForPayment(paymentHash, options?)Wait for payment success or failure.
listPeers()Inspect connected Fiber peers.
nodeInfo()Read the local Fiber node identity.
stop()Stop the node and release browser/device guards. Prefer provider disconnect().

Buttons

KeyWayLoginButton toggles login/logout. KeyWayConnectButton starts or stops Fiber and opens login first when needed. Both accept normal button attributes and label overrides.