API Reference
React SDK — API Reference
This page documents the public API surface of @nexus-cross/crossx-sdk-react.
Components
CROSSxProvider
CROSSxProviderimport { CROSSxProvider } from '@nexus-cross/crossx-sdk-react'
<CROSSxProvider config={SDKConfig}>
{children}
</CROSSxProvider>| Prop | Type | Description |
|---|---|---|
config | SDKConfig | SDK configuration (see Core SDK Config) |
children | ReactNode | Child components |
Internally creates an SDK instance and calls initialize() on mount.
Auth state is kept in sync via SDK's authChanged and addressChanged events using useSyncExternalStore.
Hooks
useAuth()
useAuth()const {
isAuthenticated,
isLoading,
error,
signIn,
signInWithCreate,
signOut,
} = useAuth()| Property | Type | Description |
|---|---|---|
isAuthenticated | boolean | true if user is logged in (reactive) |
isLoading | boolean | true during sign-in/out operations |
error | string | null | Last authentication error message |
signIn | () => Promise<AuthResult> | Open OAuth sign-in (provider selector modal) |
signInWithCreate | () => Promise<SignInWithCreateResult> | Sign in + auto wallet creation + migration |
signOut | () => Promise<void> | Clear session |
signIn()andsignInWithCreate()do not accept options. They call the underlying SDK methods directly. For specifying a provider programmatically, access the SDK viauseCROSSx().
useWallet()
useWallet()const {
address,
isLoading,
error,
signMessage,
sendTransaction,
} = useWallet()| Property | Type | Description |
|---|---|---|
address | string | null | Current wallet address (reactive) |
isLoading | boolean | Loading state |
error | string | null | Last error message |
signMessage | (chainId: string, message: string) => Promise<SignMessageResp> | Sign personal message |
sendTransaction | (chainId: string, tx: EvmTransactionRequest) => Promise<SendTxResp> | Send transaction |
For advanced wallet operations (balance, gas, provider, typed data, etc.), use
useCROSSx()to access the SDK instance directly.
useCROSSx()
useCROSSx()const { sdk, isInitialized, isAuthenticated, walletAddress } = useCROSSx()| Property | Type | Description |
|---|---|---|
sdk | CROSSxSDK | null | Direct SDK instance access |
isInitialized | boolean | true after initialize() completes |
isAuthenticated | boolean | Reactive auth state (synced via authChanged event) |
walletAddress | string | null | Reactive address (synced via addressChanged event) |
All methods from the Core SDK API are available through sdk, including selectWallet(currentAddress?) for multi-wallet selection.
Type Re-exports
All types are re-exported from @nexus-cross/crossx-sdk-core:
import type {
SDKConfig,
AuthResult,
SignMessageResp,
SendTxResp,
SignInOptions,
EvmTransactionRequest,
ChainIdValue,
} from '@nexus-cross/crossx-sdk-react'
import { ChainId } from '@nexus-cross/crossx-sdk-react'Difference from @nexus-cross/crossx-sdk-wagmi
@nexus-cross/crossx-sdk-wagmi| Feature | sdk-react | sdk-wagmi |
|---|---|---|
| wagmi dependency | None | Required |
| wagmi hooks | Not available | Full support |
| Setup complexity | Simple | Medium |
| Recommended for | Non-wagmi React apps | wagmi-based apps |
Updated 15 days ago