Getting Started

Core SDK — Getting Started

SkillDownload

This guide shows the minimum setup to run OAuth login and wallet actions with the CROSSx JavaScript SDK.

Requirements

  • Node.js 18+ or modern browser
  • TypeScript recommended (JavaScript also supported)
  • A project ID from the CROSSx management console

1) Install

npm install @nexus-cross/crossx-sdk-core
pnpm add @nexus-cross/crossx-sdk-core
yarn add @nexus-cross/crossx-sdk-core

2) Create SDK instance

import { createCROSSxSDK } from '@nexus-cross/crossx-sdk-core'

const sdk = createCROSSxSDK({
  projectId: 'YOUR_PROJECT_ID',
  appName: 'My DApp',
  theme: 'light',
  debug: true,
  receiptPolling: {
    intervalMs: 2000,
    timeoutMs: 60000,
  },
})

3) Initialize (restore session)

const session = await sdk.initialize()

if (session) {
  console.log('Session restored:', session.address)
} else {
  console.log('No previous session')
}

// Or specify which wallet to use on restore
const session = await sdk.initialize({ preferredWalletIndex: 1 })

initialize() attempts to restore a stored session on page load. Returns AuthResult if successful, null otherwise. You can pass preferredWalletIndex to select a specific wallet on restore.

4) Basic auth flow

// Ensure session is usable (restore/refresh if needed)
const ok = await sdk.ensureLoggedIn()

// Open OAuth (popup)
const result = await sdk.signIn()
// or with specific provider:
const result = await sdk.signIn({ provider: 'google' })

// Sign out
await sdk.signOut()

5) Basic wallet flow

const chainId = 'eip155:612044'

const address = await sdk.getAddress()
const { wei, formatted } = await sdk.getBalance(chainId)
console.log(`Balance: ${formatted}`)

Configuration options

OptionTypeDefaultDescription
projectIdstringRequired. Project ID from management console
appNamestringRequired. Application name displayed in confirmation modals
themestring?'light'Confirmation modal theme: 'light' | 'dark'
autoDetectThemeboolean?falseAuto-detect system dark mode via prefers-color-scheme
themeTokensSDKThemeTokens?Per-mode color overrides
locale'ko' | 'en'?'en'Modal UI language
debugboolean?trueEnable debug log output (only effective in dev builds)
receiptPollingobject?{ intervalMs, timeoutMs }
migrationobject?{ allowSkip?: boolean } — set allowSkip: false to force migration (no skip button)
loggerLoggerPort?Custom logger for routing SDK logs (always called regardless of dev/prod)
showConnectOtherWalletsboolean?falseShow "Connect with Other Wallets" button in login selector modal
useMockWalletboolean?falseEnable mock wallet for testing

Localization

The SDK ships with built-in English (en) and Korean (ko) message packs for confirmation modals.

Select a built-in language

const sdk = createCROSSxSDK({
  projectId: 'YOUR_PROJECT_ID',
  appName: 'My DApp',
  locale: 'ko', // 'en' (default) | 'ko'
})

Change language at runtime

sdk.applyLocale('ko')
sdk.applyLocale('en')

© 2025 NEXUS Co., Ltd. All Rights Reserved.