Skip to content

A simple React Native example to connect a Solana wallet (Phantom) and display the wallet address using Solana Mobile Wallet Adapter.

Notifications You must be signed in to change notification settings

dev78ashish/react-native-solana-wallet-adapter

Repository files navigation

React Native Solana Wallet Adapter

A simple, ready-to-use example for connecting Solana wallets (Phantom, etc.) to your React Native application using the Mobile Wallet Adapter (MWA) protocol.

🚀 Features

  • ✅ Connect to Phantom and other Solana mobile wallets
  • ✅ Mobile Wallet Adapter (MWA) protocol integration
  • ✅ Works on both iOS and Android
  • ✅ Built with React Native 0.83.1
  • ✅ TypeScript support
  • ✅ Ready-to-run example code

📋 Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js >= 20
  • React Native development environment set up (React Native CLI Quickstart)
  • For iOS: Xcode and CocoaPods
  • For Android: Android Studio and Java Development Kit (JDK)
  • A Solana wallet app installed on your device (e.g., Phantom, Solflare)

📦 Installation

  1. Clone the repository:
git clone https://github.com/dev78ashish/react-native-solana-wallet-adapter.git
cd react-native-solana-wallet-adapter
  1. Install dependencies:
npm install
# or
yarn install
  1. Install iOS dependencies (iOS only):
cd ios && pod install && cd ..

🏃 Running the App

Android

npm run android
# or
yarn android

iOS

npm run ios
# or
yarn ios

🔑 Key Dependencies

This project uses the following key packages:

  • @solana-mobile/mobile-wallet-adapter-protocol - Core MWA protocol
  • @solana-mobile/mobile-wallet-adapter-protocol-web3js - Web3.js integration for MWA
  • @solana/web3.js - Solana JavaScript API
  • react-native-get-random-values - Polyfill for crypto random values
  • buffer - Buffer polyfill for React Native

🛠️ Configuration

🐛 Troubleshooting

Common Issues

"Buffer is not defined"

  • Make sure react-native-get-random-values is imported at the top of your entry file
  • Ensure buffer is properly installed

"Crypto.getRandomValues() not supported"

  • Import react-native-get-random-values before any other imports

Wallet not detected

  • Ensure you have a compatible Solana wallet installed on your device
  • Make sure the wallet app is updated to the latest version

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

🔗 Useful Links

⭐ Show Your Support

If this project helped you, please give it a ⭐️!

📧 Contact

For questions or feedback, please open an issue on GitHub.


Note: This is an example project for educational purposes. Always follow security best practices when handling user wallets and transactions in production applications.

About

A simple React Native example to connect a Solana wallet (Phantom) and display the wallet address using Solana Mobile Wallet Adapter.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published