API Reference

React SDK — API Reference

This page documents the public API surface of @nexus-cross/crossx-sdk-react.

Components

CROSSxProvider

import { CROSSxProvider } from '@nexus-cross/crossx-sdk-react'

<CROSSxProvider config={SDKConfig}>
  {children}
</CROSSxProvider>
PropTypeDescription
configSDKConfigSDK configuration (see Core SDK Config)
childrenReactNodeChild components

Wraps the application (or a subtree) and provides the SDK instance via React context. Internally creates a CROSSxSDK instance, calls initialize() on mount, and keeps auth state in sync via the SDK's authChanged and addressChanged events using useSyncExternalStore. All hooks below must be used within a CROSSxProvider.

Hooks

useAuth()

const {
  isAuthenticated,
  isLoading,
  error,
  signIn,
  signInWithCreate,
  signOut,
} = useAuth()
PropertyTypeDescription
isAuthenticatedbooleantrue if user is logged in (reactive)
isLoadingbooleantrue during sign-in/out operations
errorstring | nullLast 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

Returns reactive auth state and auth action methods. isAuthenticated updates automatically when the underlying SDK emits authChanged. signIn() and signInWithCreate() do not accept options — they open the provider selector modal directly. For programmatic provider selection, access the SDK via useCROSSx().sdk.

useWallet()

const {
  address,
  isLoading,
  error,
  signMessage,
  sendTransaction,
} = useWallet()
PropertyTypeDescription
addressstring | nullCurrent wallet address (reactive)
isLoadingbooleanLoading state
errorstring | nullLast error message
signMessage(chainId: string, message: string) => Promise<SignMessageResp>Sign personal message
sendTransaction(chainId: string, tx: EvmTransactionRequest) => Promise<SendTxResp>Send transaction

Returns the current wallet address and basic wallet operation methods. address updates automatically when the SDK emits addressChanged. For advanced operations (balance, gas, typed data signing, provider access, etc.), use useCROSSx().sdk to call Core SDK methods directly.

useCROSSx()

const { sdk, isInitialized, isAuthenticated, walletAddress } = useCROSSx()
PropertyTypeDescription
sdkCROSSxSDK | nullDirect SDK instance access
isInitializedbooleantrue after initialize() completes
isAuthenticatedbooleanReactive auth state (synced via authChanged event)
walletAddressstring | nullReactive address (synced via addressChanged event)

Provides direct access to the underlying CROSSxSDK instance and reactive state from context. Use sdk to call any method from the Core SDK API, including selectWallet(currentAddress?) for multi-wallet selection. Throws if called outside a CROSSxProvider.

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

Featuresdk-reactsdk-wagmi
wagmi dependencyNoneRequired
wagmi hooksNot availableFull support
Setup complexitySimpleMedium
Recommended forNon-wagmi React appswagmi-based apps