Getting started with Expo
Generate a new application
Section titled “Generate a new application”Start from a new Expo app:
npx create-expo-app@latestpnpm dlx create-expo-app@latestbunx create-expo-app@latestInstall development build dependencies
Section titled “Install development build dependencies”Wallet UI for React Native works with Expo development builds.
npx expo install expo-dev-clientpnpm dlx expo install expo-dev-clientbunx expo install expo-dev-clientInstall the native dependencies required by Mobile Wallet Adapter:
npx expo install expo-linking expo-secure-store react-native-get-random-values react-native-url-polyfillpnpm dlx expo install expo-linking expo-secure-store react-native-get-random-values react-native-url-polyfillbunx expo install expo-linking expo-secure-store react-native-get-random-values react-native-url-polyfillInstall Wallet UI
Section titled “Install Wallet UI”npm install @wallet-ui/react-native-kitpnpm add @wallet-ui/react-native-kitbun add @wallet-ui/react-native-kitnpm install @wallet-ui/react-native-web3jspnpm add @wallet-ui/react-native-web3jsbun add @wallet-ui/react-native-web3jsBuild the app
Section titled “Build the app”Create and run a development build:
npx expo run:iosnpx expo run:androidpnpm dlx expo run:iospnpm dlx expo run:androidbunx expo run:iosbunx expo run:androidCreate app providers
Section titled “Create app providers”Create components/app-providers.tsx and configure MobileWalletProvider with the package-specific network client setup.
import { ReactNode } from 'react';import { MobileWalletProvider, createSolanaDevnet } from '@wallet-ui/react-native-kit';
const cluster = createSolanaDevnet();
export function AppProviders({ children }: { children: ReactNode }) { return ( <MobileWalletProvider cluster={cluster} identity={{ name: 'Wallet UI Example Expo' }}> {children} </MobileWalletProvider> );}import { ReactNode } from 'react';import { MobileWalletProvider } from '@wallet-ui/react-native-web3js';
const chain = 'solana:devnet';const endpoint = 'https://api.devnet.solana.com';
export function AppProviders({ children }: { children: ReactNode }) { return ( <MobileWalletProvider chain={chain} endpoint={endpoint} identity={{ name: 'Wallet UI Example Expo' }}> {children} </MobileWalletProvider> );}Wrap the app with the provider:
import { Stack } from 'expo-router';import { AppProviders } from '../components/app-providers';
export default function RootLayout() { return ( <AppProviders> <Stack /> </AppProviders> );}You can now use the React Native hooks in your app.
Connect to a wallet
Section titled “Connect to a wallet”Add a simple connection component to confirm the provider is working.
import { useMobileWallet } from '@wallet-ui/react-native-kit';import { useCallback } from 'react';import { Button, Text, View } from 'react-native';
export default function IndexScreen() { const { account, connect, disconnect } = useMobileWallet();
const handleConnect = useCallback(async () => { await connect(); }, [connect]);
const handleDisconnect = useCallback(async () => { await disconnect(); }, [disconnect]);
return ( <View> {account ? ( <> <Text>Connected to: {account.address}</Text> <Button title="Disconnect" onPress={handleDisconnect} /> </> ) : ( <Button title="Connect Wallet" onPress={handleConnect} /> )} </View> );}import { useMobileWallet } from '@wallet-ui/react-native-web3js';import { useCallback } from 'react';import { Button, Text, View } from 'react-native';
export default function IndexScreen() { const { account, connect, disconnect } = useMobileWallet();
const handleConnect = useCallback(async () => { await connect(); }, [connect]);
const handleDisconnect = useCallback(async () => { await disconnect(); }, [disconnect]);
return ( <View> {account ? ( <> <Text>Connected to: {account.address}</Text> <Button title="Disconnect" onPress={handleDisconnect} /> </> ) : ( <Button title="Connect Wallet" onPress={handleConnect} /> )} </View> );}