Skip to content

Getting started with Expo

Start from a new Expo app:

Terminal window
npx create-expo-app@latest

Wallet UI for React Native works with Expo development builds.

Terminal window
npx expo install expo-dev-client

Install the native dependencies required by Mobile Wallet Adapter:

Terminal window
npx expo install expo-linking expo-secure-store react-native-get-random-values react-native-url-polyfill
Terminal window
npm install @wallet-ui/react-native-kit

Create and run a development build:

Terminal window
npx expo run:ios
npx expo run:android

Create components/app-providers.tsx and configure MobileWalletProvider with the package-specific network client setup.

components/app-providers.tsx
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>
);
}

Wrap the app with the provider:

app/_layout.tsx
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.

Add a simple connection component to confirm the provider is working.

app/index.tsx
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>
);
}