Skip to content

feat(sdk-react): react native support with /native entry point (#123)#150

Open
ZeePearl56 wants to merge 1 commit into
wraith-protocol:developfrom
ZeePearl56:feat/123-react-native-support-sdk-react
Open

feat(sdk-react): react native support with /native entry point (#123)#150
ZeePearl56 wants to merge 1 commit into
wraith-protocol:developfrom
ZeePearl56:feat/123-react-native-support-sdk-react

Conversation

@ZeePearl56

Copy link
Copy Markdown

Summary

Adds React Native support to @wraith-protocol/sdk-react via a new /native subpath export. The existing web entry point is completely unchanged. 990 tests pass, 0 failures.

Changes

Platform abstraction layer (src/platform.ts)

  • Defines PlatformStorage, PlatformCrypto, and Platform interfaces
  • Default web implementation using Web Crypto API + localStorage
  • Lazy getPlatform() / setPlatform() registry pattern (no circular deps)
  • Exported from hooks.ts for consumer access

React Native platform (src/platform-native.ts)

  • Storage via @react-native-async-storage/async-storage
  • Crypto via expo-crypto (SHA-256) with fallback to globalThis.crypto.getRandomValues
  • setup() installs polyfills: react-native-get-random-values, Buffer

New entry points

  • src/native.ts — calls setPlatform(nativePlatform) then re-exports all hooks
  • @wraith-protocol/sdk-react/native subpath export added to package.json exports and tsup.config.ts
  • RN packages are externalized — no conditional-import errors in web bundles

Example: examples/stellar-react-native-receive/

  • Bare React Native (no Expo Go) receive example using @wraith-protocol/sdk-react/native
  • Full metro.config.js, babel.config.js, tsconfig.json setup
  • Monorepo-compatible with local SDK aliasing

Files changed

File Status
packages/sdk-react/src/platform.ts new — platform abstraction interface + web impl
packages/sdk-react/src/platform-native.ts new — React Native platform impl
packages/sdk-react/src/native.ts new — /native entry point
packages/sdk-react/src/hooks.ts modified — re-exports getPlatform/setPlatform/Platform
packages/sdk-react/src/env.d.ts modified — added RN module type declarations
packages/sdk-react/package.json modified — added ./native export
packages/sdk-react/tsup.config.ts modified — added native.ts entry, RN externals
examples/stellar-react-native-receive/ new — bare RN receive example (9 files)

Verification

  • pnpm build — all entry points build cleanly (index + native)
  • pnpm test — 990 tests pass (0 failures, 5 skipped — same as before)
  • ✅ Existing web hooks pass unchanged (useStellarStealthKeys, useStellarBalance)
  • pnpm format:check — all files use Prettier style

Closes #123

@drips-wave

drips-wave Bot commented Jul 24, 2026

Copy link
Copy Markdown

@ZeePearl56 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

React Native support in sdk-react

2 participants