Skip to main content
@ckb-ccc/connector-react is the recommended integration layer for React and Next.js applications. It provides a context Provider, a useCcc hook that exposes the full connector state, and a useSigner hook that returns the active signer whenever a wallet is connected.

Installation

Provider

Wrap your application (or the subtree that needs wallet access) with ccc.Provider. It renders the wallet selection modal and makes the connector context available to all descendant components.

Props

All props are optional except children.

useCcc

useCcc() returns the full connector context. Call it inside any component that is a descendant of ccc.Provider.

Return value

Calling useCcc() outside of a ccc.Provider subtree throws an error. Make sure every component that uses this hook is wrapped by the provider.

useSigner

useSigner() is a convenience hook that returns the active ccc.Signer directly. It returns undefined while no wallet is connected.

Full example

The following example shows a minimal React app that connects a wallet and sends CKB.
In Next.js App Router, add "use client" to any file that imports from @ckb-ccc/connector-react. The Provider and hooks use React context and browser APIs that are not available in server components.