From 0a93fe49f7d0e3736c60d0da6705bc2dd3b7aac7 Mon Sep 17 00:00:00 2001 From: nacho <25931366+ignaciosantise@users.noreply.github.com> Date: Tue, 20 May 2025 14:34:34 -0300 Subject: [PATCH 1/7] chore: adding new docs for react native multichain --- appkit/react-native/core/components.mdx | 18 +- appkit/react-native/core/hooks.mdx | 384 +++++++--------- appkit/react-native/core/installation.mdx | 519 ++++++++++++---------- appkit/react-native/core/options.mdx | 450 +++++++++++-------- docs.json | 4 - 5 files changed, 731 insertions(+), 644 deletions(-) diff --git a/appkit/react-native/core/components.mdx b/appkit/react-native/core/components.mdx index 4031a0aaf..75474df95 100644 --- a/appkit/react-native/core/components.mdx +++ b/appkit/react-native/core/components.mdx @@ -2,25 +2,27 @@ title: Components --- -# Components +AppKit comes with a set of pre-built UI components to help you quickly integrate wallet connection and display functionalities into your React Native application. You can import them directly from `@reown/appkit-react-native`. -AppKit comes with a set of components in case you want to integrate fast. -You can import them from `@reown/appkit-wagmi-react-native` or `@reown/appkit-ethers-react-native` - -### List of components available in AppKit package ### `` +The `AppKitButton` is a versatile component that intelligently adapts its appearance and behavior based on the current connection status. +- When no wallet is connected, it functions as a "Connect Wallet" button. +- When a wallet is connected, it functions as an "Account" button, typically displaying account information and a disconnect option. + | Variable | Description | Type | | -------------- | ---------------------------------------------------- | ------------------ | | `disabled` | Enable or disable the button. | `boolean` | | `balance` | Show or hide the user's balance. | `'show' \| 'hide'` | | `size` | Default size for the button. | `'md' \| 'sm'` | -| `label` | The text shown in the button. | `string` | +| `label` | The text shown in the button (primarily when disconnected). | `string` | | `loadingLabel` | The text shown in the button when the modal is open. | `string` | ### `` +This button is specifically designed to display when a user is connected. It typically shows account information and provides a way to disconnect or manage the connected account. + | Variable | Description | Type | | ---------- | -------------------------------- | ------------------ | | `disabled` | Enable or disable the button. | `boolean` | @@ -28,6 +30,8 @@ You can import them from `@reown/appkit-wagmi-react-native` or `@reown/appkit-et ### `` +This button is primarily used to initiate the connection process when no user is connected. + | Variable | Description | Type | | -------------- | ---------------------------------------------------- | -------------- | | `size` | Default size for the button. | `'md' \| 'sm'` | @@ -36,6 +40,8 @@ You can import them from `@reown/appkit-wagmi-react-native` or `@reown/appkit-et ### `` +This button displays the currently active network of the connection. When pressed, it opens the network selection view within the AppKit modal, allowing users to switch networks. + | Variable | Description | Type | | ---------- | ----------------------------- | --------- | | `disabled` | Enable or disable the button. | `boolean` | diff --git a/appkit/react-native/core/hooks.mdx b/appkit/react-native/core/hooks.mdx index 709edc934..31e81d882 100644 --- a/appkit/react-native/core/hooks.mdx +++ b/appkit/react-native/core/hooks.mdx @@ -2,262 +2,194 @@ title: Hooks --- -import WagmiHooks from "/snippets/appkit/react-native/wagmi/hooks.mdx"; -import EthersHooks from "/snippets/appkit/react-native/ethers/hooks.mdx"; -import Ethers5Hooks from "/snippets/appkit/react-native/ethers5/hooks.mdx"; +AppKit for React Native provides a set of hooks to interact with the wallet connection lifecycle, access connection state, and control the modal. -## useAppKit +All hooks are imported from `@reown/appkit-react-native`. -Control the modal with the `useAppKit` hook +## `useAppKit()` - +This is the primary hook to get AppKit state and control the modal. - -```ts -import { useAppKit } from '@reown/appkit-wagmi-react-native' +```typescript +import { useAppKit } from '@reown/appkit-react-native'; -export default function Component() { - const { open, close } = useAppKit() +export default function MyComponent() { + const { + // Modal Control + open, // Function to open the modal, optionally with a specific view (e.g., open({ view: 'Networks' })) + close, // Function to close the modal + isOpen, // Boolean indicating if the modal is currently open -open() - -//... + // Actions + disconnect, // Function to disconnect the current session + switchNetwork, // Function to attempt to switch to a different chain/network (e.g., switchNetwork(network: AppKitNetwork)) + } = useAppKit(); } - -```` - - - -```ts -import { useAppKit } from '@reown/appkit-ethers-react-native' - -export default function Component() { - const { open, close } = useAppKit() - - open() - - //... -} -```` - - - - -```ts -import { useAppKit } from '@reown/appkit-ethers5-react-native' - -export default function Component() { - const { open, close } = useAppKit() - -open() - -//... -} - -```` - - - - -You can also select the modal's view when calling the `open` function - -```ts -open({ view: 'Account' }) - -// to connect and show multi wallets view -open({ view: 'Connect'}) - -// to connect and show only solana wallets -open({ view: 'Connect', namespace: 'solana' }) - -// to connect and show only bitcoin wallets -open({ view: 'Connect', namespace: 'bip122' }) - -// to connect and show only ethereum wallets -open({ view: 'Connect', namespace: 'eip155' }) -```` - -List of views you can select - -| Variable | Description | -| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `Connect` | Principal view of the modal - default view when disconnected. A `namespace` can be selected to connect to a specific network (solana, bip122 or eip155). | -| `Account` | User profile - default view when connected. | -| `Networks` | List of available networks - you can select and target a specific network before connecting. | -| `WhatIsANetwork` | "What is a network" onboarding view. | -| `WhatIsAWallet` | "What is a wallet" onboarding view. | - -## useAppKitState - -Get the current value of the modal's state - - - - -```ts -import { useAppKitState } from '@reown/appkit-wagmi-react-native' - -const { open, selectedNetworkId } = useAppKitState() - -```` - - - -```ts -import { useAppKitState } from '@reown/appkit-ethers-react-native' - -const { open, selectedNetworkId } = useAppKitState() -``` - - - - -```ts -import { useAppKitState } from '@reown/appkit-ethers5-react-native' - -const { open, selectedNetworkId } = useAppKitState() ``` - - - - -The modal state consists of two reactive values: - -| State | Description | Type | -|--------------------|-----------------------------------------------------------------------------|-----------| -| `open` | Open state will be true when the modal is open and false when closed. | `boolean` | -| `selectedNetworkId`| The current chain id selected by the user. | `number` | - -## useAppKitEvents -Get the last tracked modal event. The hook accepts an optional callback function that is executed when the event is triggered. +Opening the Modal with a Specific View - +You can direct the modal to open to a specific view using the `open` function: - -```ts -import { useAppKitEvents } from '@reown/appkit-wagmi-react-native' - -const event = useAppKitEvents(event => { - // your code here -}) +```typescript +open({ view: 'Account' }); // Opens to the account view if connected +open({ view: 'Connect' }); // Opens to the wallet selection view +open({ view: 'Networks' }); // Opens to the network selection view ``` - - - -```ts -import { useAppKitEvents } from '@reown/appkit-ethers-react-native' - -const event = useAppKitEvents(event => { - // your code here -}) +Here is a list of possible views you can select: + +| Variable | Description | +| ---------------- | ------------------------------------------------------------------------------------------------ | +| `Connect` | Principal view of the modal - default view when disconnected. | +| `Account` | User profile - default view when connected. | +| `Networks` | List of available networks - you can select and target a specific network before connecting. | +| `WhatIsANetwork` | "What is a network" onboarding view. | +| `WhatIsAWallet` | "What is a wallet" onboarding view. | +{/* Add any other views if available, and verify these from the modal\'s implementation */} + +## `useAccount()` + +This is the primary hook to access the details of the connected account. +The exact properties returned by this hook should be verified against the source code. + +```typescript +import { useAccount } from '@reown/appkit-react-native'; + +export default function MyComponent() { + const { + address, // String, the connected account address (e.g., '0x...', 'Sol...', 'bc1...') + chainId, // Number or String, the chain ID of the currently active connection + isConnected, // Boolean, true if a wallet is connected on the current chain/namespace + } = useAccount(); + + if (isConnected) { + return ( +
+

Connected to chain: {chainId}

+

Address: {address}

+
+ ); + } + return

Not Connected

; +} ``` -
- - -```ts -import { useAppKitEvents } from '@reown/appkit-ethers5-react-native' - -const event = useAppKitEvents(event => { - // your code here -}) +## `useProvider()` + +This hook provides access to the underlying chain-specific provider for the currently active connection. This is useful for performing direct interactions with the blockchain that go beyond the standard AppKit actions. + +By default, `useProvider()` returns the provider for the currently active network. You can also get a provider for a specific namespace by passing an argument, e.g., `useProvider('eip155')`, `useProvider('solana')`, or `useProvider('bitcoin')`. + +```typescript +import { useProvider, useAccount } from '@reown/appkit-react-native'; + +// Example for EVM chains (using ethers.js) +// import { BrowserProvider, JsonRpcSigner } from 'ethers'; + +// Example for Solana +// import { Connection } from '@solana/web3.js'; + +export default function ChainSpecificActions() { + // Get provider for the current active network + const { provider, providerType } = useProvider(); + // Or, to get a specific provider: + // const { provider: evmProvider, providerType: evmType } = useProvider('eip155'); + // const { provider: solanaProvider, providerType: solanaType } = useProvider('solana'); + + const { chainId, address, isConnected } = useAccount(); + + if (!isConnected || !provider) { + return

Please connect your wallet.

; + } + + const handleSignMessageEVM = async () => { + if (providerType === 'eip155' && address) { + // const ethersProvider = new BrowserProvider(provider); // Or however the provider is typed + // const signer = await ethersProvider.getSigner(); + // const signature = await signer.signMessage('Hello from AppKit!'); + // console.log('EVM Signature:', signature); + alert('EVM sign message functionality to be implemented using the provider.'); + } + }; + + const handleSignMessageSolana = async () => { + if (providerType === 'solana' && address) { + // const solanaConnection = provider as Connection; // Cast to Solana Connection + // const message = `Hello from AppKit! Address: ${address}`; + // const encodedMessage = new TextEncoder().encode(message); + // const signature = await provider.signMessage(encodedMessage, 'utf8'); // Assuming provider has signMessage + // console.log('Solana Signature:', signature); + alert('Solana sign message functionality to be implemented using the provider.'); + } + }; + + // Similar functions can be created for Bitcoin + + return ( +
+

Current Chain ID: {chainId}

+

Provider Type: {providerType || 'N/A'}

+ {providerType === 'eip155' && } + {providerType === 'solana' && } + {/* Add buttons for other provider types as needed */} +
+ ); +} ``` -
- -
- -## useAppKitEventSubscription - -Subscribe to modal specific events - - - - -```ts -import { useAppKitEventSubscription } from '@reown/appkit-wagmi-react-native' +Refer to the example usage in: +* [EVM + Ethers](https://github.com/reown-com/appkit-react-native/blob/feat/multichain/apps/native/src/views/EthersActionsView.tsx) +* [EVM + Wagmi](https://github.com/reown-com/appkit-react-native/blob/feat/multichain/apps/native/src/views/WagmiActionsView.tsx) (Note: Wagmi has its own provider/signer abstractions, so `useProvider` might be used differently or in conjunction with Wagmi's hooks) +* [Solana](https://github.com/reown-com/appkit-react-native/blob/feat/multichain/apps/native/src/views/SolanaActionsView.tsx) +* [Bitcoin](https://github.com/reown-com/appkit-react-native/blob/feat/multichain/apps/native/src/views/BitcoinActionsView.tsx) -useAppKitEventSubscription('MODAL_OPEN', newEvent => { - // your code here -}); -``` +## `useWalletInfo()` - +This hook provides metadata about the connected wallet. The exact structure of `walletInfo` can be found in the `WalletInfo` type definition in [packages/common/src/utils/TypeUtil.ts](https://github.com/reown-com/appkit-react-native/blob/f70c343eb954419ceb43c0cd922a5929d8462a56/packages/common/src/utils/TypeUtil.ts#L365). - -```ts -import { useAppKitEventSubscription } from '@reown/appkit-ethers-react-native' +```typescript +import { useWalletInfo } from '@reown/appkit-react-native'; -useAppKitEventSubscription('MODAL_OPEN', newEvent => { - // your code here -}); -``` - +export default function WalletDetails() { + const { walletInfo } = useWalletInfo(); // Verify exact return structure from source - -```ts -import { useAppKitEventSubscription } from '@reown/appkit-ethers5-react-native' + if (!walletInfo) { + return

No wallet connected or info unavailable.

; + } -useAppKitEventSubscription('MODAL_OPEN', newEvent => { - // your code here -}); + return ( +
+

Connected Wallet:

+

Name: {walletInfo.name}

+

Icon: {walletInfo.icon && {walletInfo.name}}

+ {/* Refer to TypeUtil.ts for other walletInfo properties e.g., rdns, id etc. */} +
+ ); +} ``` -
- -
- -## useWalletInfo - -Get the metadata information from the connected wallet - - - - -```ts -import { useWalletInfo } from '@reown/appkit-wagmi-react-native' - -const { walletInfo } = useWalletInfo() -```` +## `useAppKitEventSubscription()` - +AppKit emits events for various state changes and actions. You can subscribe to these events to react accordingly in your application. The full list of event types and their payloads can be found in `AppKitEvents` within [packages/core/src/utils/TypeUtil.ts](https://github.com/reown-com/appkit-react-native/blob/f70c343eb954419ceb43c0cd922a5929d8462a56/packages/core/src/utils/TypeUtil.ts#L369). +This hook provides a way to subscribe to a specific modal event and receives a callback function that is executed when the event is triggered. - -```ts -import { useWalletInfo } from '@reown/appkit-ethers-react-native' +```typescript +import { useAppKitEventSubscription } from '@reown/appkit-react-native'; -const { walletInfo } = useWalletInfo() +export default function EventLogger() { + useAppKitEventSubscription('MODAL_OPEN', event => { console.log('Modal opened!', event); }); -```` - + useAppKitEventSubscription('CONNECT_SUCCESS', event => { console.log('Wallet connected!', event); }); - -```ts -import { useWalletInfo } from '@reown/appkit-ethers5-react-native' - -const { walletInfo } = useWalletInfo() -```` - - - - - -## Ethereum Library - - - - - - + return null; +} +``` - - - +## Deprecated Hooks - - - +### `useAppKitState()` +The functionality of `useAppKitState` (which previously exposed `open` (modal state) and `selectedNetworkId`) is now incorporated into `useAppKit()` (for modal control like `isOpen`) and `useAccount()` (for `chainId`). - +### `useDisconnect()` +The functionality of `useDisconnect` (which previously exposed a `disconnect` function) is now available directly from the `useAppKit()` hook. diff --git a/appkit/react-native/core/installation.mdx b/appkit/react-native/core/installation.mdx index 25b031ed5..9cfcc1af6 100644 --- a/appkit/react-native/core/installation.mdx +++ b/appkit/react-native/core/installation.mdx @@ -4,183 +4,325 @@ title: Installation import CloudBanner from "/snippets/cloud-banner.mdx"; -import WagmiInstallation from "/snippets/appkit/react-native/wagmi/about/installation.mdx"; -import WagmiInstallationExpo from "/snippets/appkit/react-native/wagmi/about/installation-expo.mdx"; -import WagmiImplementation from "/snippets/appkit/react-native/wagmi/about/implementation.mdx"; -import WagmiCoinbase from "/snippets/appkit/react-native/wagmi/about/coinbase.mdx"; +AppKit for React Native enables seamless integration with multiple blockchain ecosystems, including EVM chains (like Ethereum, Polygon, etc.), Solana, and Bitcoin. It provides a unified API to manage wallet connections, interact with different chains, and build rich multi-chain applications. -import Ethers5Installation from "/snippets/appkit/react-native/ethers5/about/installation.mdx"; -import Ethers5InstallationExpo from "/snippets/appkit/react-native/ethers5/about/installation-expo.mdx"; -import Ethers5Implementation from "/snippets/appkit/react-native/ethers5/about/implementation.mdx"; -import Ethers5Coinbase from "/snippets/appkit/react-native/ethers5/about/coinbase.mdx"; - -import EthersInstallation from "/snippets/appkit/react-native/ethers/about/installation.mdx"; -import EthersInstallationExpo from "/snippets/appkit/react-native/ethers/about/installation-expo.mdx"; -import EthersImplementation from "/snippets/appkit/react-native/ethers/about/implementation.mdx"; -import EthersCoinbase from "/snippets/appkit/react-native/ethers/about/coinbase.mdx"; - -# React Native - -## Introduction - -AppKit has support for [Wagmi](https://wagmi.sh) and [Ethers](https://docs.ethers.org/v6/). Choose one of these Ethereum libraries to get started. +At the core of AppKit is a centralized `AppKit` instance that handles connection logic, manages various chain adapters, and provides data to your application via a React Context. ## Installation - - - - - - +Installation is a two-step process: +1. Install the core AppKit library. +2. Install the specific chain adapters you need for your application. + + +### Core Library - +```bash +npx expo install @reown/appkit-react-native @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat expo-application +``` + - - - - - - - +### Core Library - +Install our core library and it's dependencies +```bash +npm install @reown/appkit-react-native @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat +``` +On iOS, use CocoaPods to add the native modules to your project: - +```bash +npx pod-install +``` - - +### Chain Adapters +For React Native CLI projects, use `npm install ...` or `yarn add ...`. - +Install the adapters for the chains you intend to support: + +

For EVM-compatible chains, you can choose between the Ethers.js-based adapter or the Wagmi-based adapter. You should install the one that best fits your project's existing setup or preference.

+ + + +

This adapter uses Ethers.js for interacting with EVM chains.

+ ```bash + npx expo install @reown/appkit-ethers-react-native + ``` +

To initialize the Ethers adapter:

+ ```typescript + import { EthersAdapter } from '@reown/appkit-ethers-react-native'; + + const projectId = 'YOUR_PROJECT_ID'; // Obtain from Cloud + const ethersAdapter = new EthersAdapter({ projectId }); + ``` +
+ +

This adapter integrates with Wagmi for state management and EVM interactions. It requires a few more setup steps compared to the Ethers adapter.

+ +

1. Install Packages:

+

First, install the Reown Wagmi adapter and its peer dependencies:

+ ```bash + # Install the Reown Wagmi adapter + npx expo install @reown/appkit-wagmi-react-native + + # Install Wagmi and its required peer dependencies + npx expo install wagmi viem@2.x @tanstack/react-query + ``` + +

2. Configure Wagmi and Initialize Adapter:

+

The `WagmiAdapter` requires a Wagmi configuration object. You'll create this using `createConfig` from `wagmi` (we recommend aliasing it, e.g., to `createWagmiConfig`, if you also use `createConfig` from AppKit). This config, defining your chains and transports, is then passed to the `WagmiAdapter` during its initialization within your AppKit setup file (e.g., `src/AppKitConfig.ts`).

+ + ```typescript + // src/AppKitConfig.ts (or wherever you configure AppKit) + import "@walletconnect/react-native-compat"; + import { createAppKit } from '@reown/appkit-react-native'; // Assuming other AppKit imports are present + import { WagmiAdapter } from '@reown/appkit-wagmi-react-native'; + import { http, createConfig as createWagmiCoreConfig } from 'wagmi'; + import { mainnet, sepolia } from 'wagmi/chains'; // Or other chains you need + // ... other adapter imports if any + + const projectId = 'YOUR_PROJECT_ID'; // Obtain from Cloud + + export const wagmiAdapter = new WagmiAdapter({ + projectId, + networks: [mainnet, sepolia], // Add all chains you want to support + }); + + export const appKit = createAppKit({ + projectId, + // Add your AppKitNetwork array for 'networks' matching the wagmiCoreConfig chains + // networks: [mainnet, sepolia, ...], + adapters: [wagmiAdapter, /* other adapters for other chain types */], + // ... other AppKit options + }); + ``` + Ensure the `networks` array in `AppKit` options includes the chains defined in `wagmiAdapter`. + +

3. Set up Context Providers in App.tsx:

+

Wagmi requires its own context provider (`WagmiProvider`) and also relies on TanStack Query (`QueryClientProvider`). You'll need to wrap your application (or the relevant part of it) with these providers, in addition to the `AppKitProvider`. The `config` prop for `WagmiProvider` must be the `wagmiConfig` instance from your initialized `WagmiAdapter`. Refer to the official Wagmi documentation for details on provider setup.

+ + ```tsx + // App.tsx + import React from 'react'; + import { AppKitProvider } from '@reown/appkit-react-native'; + import { appKit, wagmiAdapter } from './AppKitConfig'; // Your configured AppKit instance + import YourAppRootComponent from './YourAppRootComponent'; // Your main app component + + import { WagmiProvider } from 'wagmi'; + import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; + + const queryClient = new QueryClient(); + + function App() { + return ( + + + + + + + + ); + } + + export default App; + ``` + +

For a practical implementation example, you can refer to the Reown AppKit + Wagmi example on GitHub.

+
+
+
+ +

For Solana, install the Solana adapter:

+ ```bash + npx expo install @reown/appkit-solana-react-native + ``` +

To initialize the Solana adapter:

+ ```typescript + import { SolanaAdapter } from '@reown/appkit-solana-react-native'; + + const projectId = 'YOUR_PROJECT_ID'; // Obtain from Cloud + const solanaAdapter = new SolanaAdapter({ projectId }); + ``` +
+ +

For Bitcoin, install the Bitcoin adapter:

+ ```bash + npx expo install @reown/appkit-bitcoin-react-native + ``` +

To initialize the Bitcoin adapter:

+ ```typescript + import { BitcoinAdapter } from '@reown/appkit-bitcoin-react-native'; + + const projectId = 'YOUR_PROJECT_ID'; // Obtain from Cloud + const bitcoinAdapter = new BitcoinAdapter({ projectId }); + ``` +
+
- - - - - - - - - - +## Implementation +### 1. Initialize AppKit - +First, create an instance of `AppKit`. This is where you'll configure your project ID (if using WalletConnect features) and define the chains your application will support, along with their respective adapters. - + +To ensure proper functioning with React Native, make sure `import "@walletconnect/react-native-compat";` is the very first line in your configuration file (e.g., `AppKitConfig.ts`), even before other imports. This import handles necessary polyfills. + - +```typescript +// src/AppKitConfig.ts (or wherever you prefer to configure it) +import "@walletconnect/react-native-compat"; +import { createAppKit, bitcoin, solana, type AppKitNetwork } from '@reown/appkit-react-native'; +import { EthersAdapter } from '@reown/appkit-ethers-react-native'; +import { SolanaAdapter } from '@reown/appkit-solana-react-native'; +import { BitcoinAdapter } from '@reown/appkit-bitcoin-react-native'; + +// You can use 'viem/chains' or define your own chains using `AppKitNetwork` type. Check Options/networks for more detailed info +import { mainnet, polygon } from 'viem/chains'; + +const projectId = 'YOUR_PROJECT_ID'; // Obtain from Cloud + +const ethersAdapter = new EthersAdapter({ + projectId +}); + +const solanaAdapter = new SolanaAdapter({ + projectId +}); + +const bitcoinAdapter = new BitcoinAdapter({ + projectId +}); + +export const appKit = createAppKit({ + projectId, + networks: [mainnet, polygon, solana, bitcoin], + defaultNetwork: mainnet, // Optional: set a default network + adapters: [ethersAdapter, solanaAdapter, bitcoinAdapter], + + // Other AppKit options (e.g., metadata for your dApp) + metadata: { + name: 'My Awesome dApp', + description: 'My dApp description', + url: 'https://myapp.com', + icons: ['https://myapp.com/icon.png'], + redirect: { + native: "YOUR_APP_SCHEME://", + universal: "YOUR_APP_UNIVERSAL_LINK.com", + }, + } +}); +``` +### 2. Provide AppKit Instance +Wrap your application with the `AppKitProvider` to make the `AppKit` instance available throughout your component tree via context. - +```tsx +// App.tsx +import React from 'react'; +import { AppKitProvider } from '@reown/appkit-react-native'; +import { appKit } from './AppKitConfig'; // Your configured AppKit instance +import YourAppRootComponent from './YourAppRootComponent'; + +function App() { + return ( + + + + ); +} - +export default App; +``` -
+### 3. Render AppKit UI -
+To display the AppKit modal and other potential UI elements, you need to include the `` component in your application. If you want the modal to be accessible from anywhere in your app, it's best to place this component within your main application root component (e.g., the `YourAppRootComponent` from the example above, or directly in `App.tsx` if it serves as your main layout). -
+```tsx +// YourAppRootComponent.tsx (or App.tsx if it contains your main layout) +import React from 'react'; +import { AppKit } from '@reown/appkit-react-native'; +// ... other imports for your app components like ConnectButton, etc. +import ConnectButton from './components/ConnectButton'; // Example import + +function YourAppRootComponent() { + return ( + <> + {/* Your application's content */} + + {/* ... other components ... */} + + {/* Add the AppKit component here to render its UI (e.g., the modal) */} + + + ); +} -## Implementation +export default YourAppRootComponent; +``` - +### 4. Using AppKit in Components - - - +You can now access AppKit functionalities (like connecting, getting account state, etc.) using hooks provided by the library. - - - +```tsx +// components/ConnectButton.tsx +import { useAppKit, useAccount } from '@reown/appkit-react-native'; + +function ConnectButton() { + const { open, disconnect } = useAppKit(); + const { address, isConnected, chainId } = useAccount(); + + if (isConnected) { + return ( +
+

Connected to: {chainId}

+

Address: {address}

+ +
+ ); + } - - - + return ; +} -
+export default ConnectButton; +``` +For detailed examples on specific actions like signing messages, sending transactions, or switching networks, please refer to the [Hooks](./hooks#useprovider) and [Examples](#examples) sections. ## Getting Support ๐Ÿ™‹ Reown is committed to delivering the best developer experience. -If you have any questions, feature requests, or bug reports, feel free to open an issue on [GitHub](https://github.com/reown-com/appkit-react-native)! +If you have any questions, feature requests, or bug reports, feel free to open an issue on [GitHub](https://github.com/reown-com/appkit-react-native) ## Enable Wallet Detection -Make sure your have `@walletconnect/react-native-compat@2.10.5` or higher. +Make sure your have `@walletconnect/react-native-compat` installed. To enable AppKit to detect wallets installed on the device, you need to make specific changes to the native code of your project. - - - - - -1. Open your `Info.plist` file. -2. Locate the `LSApplicationQueriesSchemes` section. -3. Add the desired wallet schemes as string entries within the ``. These schemes represent the wallets you want to detect. -4. Refer to our [Info.plist example file](https://github.com/WalletConnect/react-native-examples/blob/main/dapps/ModalUProvider/ios/ModalUProvider/Info.plist) for a detailed illustration. - -Example: - -```xml -LSApplicationQueriesSchemes - - metamask - trust - safe - rainbow - uniswap - - -``` - - - - - -1. Open your `AndroidManifest.xml` file. -2. Locate the `` section. -3. Add the desired wallet package names as `` entries within the ``. These package names correspond to the wallets you want to detect. -4. Refer to our [AndroidManifest.xml example file](https://github.com/WalletConnect/react-native-examples/blob/main/dapps/ModalUProvider/android/app/src/main/AndroidManifest.xml) for detailed guidance. - -Example: - -```xml - - - - - - - -``` - - - - - - - + + @@ -278,120 +420,53 @@ module.exports = createRunOncePlugin( - - - -## Enable Coinbase Wallet + - - -Follow these steps to install Coinbase SDK in your project along with our Coinbase package. Check here for more detailed information. - -- Note: Coinbase SDK is [not compatible with Expo Go](https://github.com/MobileWalletProtocol/wallet-mobile-sdk/issues/206) - -1. Enable Expo Modules in your project running: - -``` -npx install-expo-modules@latest -``` + +1. Open your `Info.plist` file. +2. Locate the `LSApplicationQueriesSchemes` section. +3. Add the desired wallet schemes as string entries within the ``. These schemes represent the wallets you want to detect. +4. Refer to our [Info.plist example file](https://github.com/WalletConnect/react-native-examples/blob/main/dapps/ModalUProvider/ios/ModalUProvider/Info.plist) for a detailed illustration. -2. Install Coinbase SDK +Example: +```xml +LSApplicationQueriesSchemes + + metamask + trust + safe + rainbow + uniswap + + ``` -yarn add @coinbase/wallet-mobile-sdk react-native-mmkv -``` - -3. Install our custom connector - - - - - ``` yarn add @reown/appkit-coinbase-wagmi-react-native ``` - - - ``` yarn add @reown/appkit-coinbase-ethers-react-native ``` - - - - ``` yarn add @reown/appkit-coinbase-ethers-react-native ``` - - -4. Run pod-install - -``` -npx pod-install -``` + -5. Enable Deeplink handling in your project following React Native docs +1. Open your `AndroidManifest.xml` file. +2. Locate the `` section. +3. Add the desired wallet package names as `` entries within the ``. These package names correspond to the wallets you want to detect. +4. Refer to our [AndroidManifest.xml example file](https://github.com/WalletConnect/react-native-examples/blob/main/dapps/ModalUProvider/android/app/src/main/AndroidManifest.xml) for detailed guidance. -6. Add Coinbase package in your AndroidManifest.xml and Info.Plist +Example: ```xml -// AndroidManifest.xml - - - + + + + + ``` -```xml -// Info.plist - -LSApplicationQueriesSchemes - - - cbwallet - -``` - -7. Add Coinbase response handler in your app. More info here - -```tsx -import { handleResponse } from "@coinbase/wallet-mobile-sdk"; - -// Your app's deeplink handling code -useEffect(() => { - const sub = Linking.addEventListener("url", ({ url }) => { - const handledBySdk = handleResponse(new URL(url)); - if (!handledBySdk) { - // Handle other deeplinks - } - }); - - return () => sub.remove(); -}, []); -``` - - - - - - - - - - - - - - -Check Coinbase docs for more detailed information. - - - - - Coinbase SDK doesn't support Expo Projects. More info - - here - @@ -439,15 +514,3 @@ Want to see AppKit in action? Download our sample AppKit apps below and explore - [Android Build (Firebase)](https://appdistribution.firebase.google.com/pub/i/0297fbd3de8f1e3f) - [iOS Build (Testflight)](https://testflight.apple.com/join/YW2jD2s0) -## Tutorial - - diff --git a/appkit/react-native/core/options.mdx b/appkit/react-native/core/options.mdx index 392d117de..c14bf3868 100644 --- a/appkit/react-native/core/options.mdx +++ b/appkit/react-native/core/options.mdx @@ -2,92 +2,175 @@ title: Options --- -The following options can be passed to the `createAppKit` function: +AppKit for React Native is configured by calling the `createAppKit` function and passing a configuration object to it. This function initializes and returns the AppKit instance that you will use throughout your application, typically by providing it via the `AppKitProvider`. + +```typescript +import { createAppKit } from '@reown/appkit-react-native'; +import { EthersAdapter } from '@reown/appkit-ethers-react-native'; // Example adapter +import { SolanaAdapter } from '@reown/appkit-solana-react-native'; // Example adapter +// Import other adapters as needed (e.g., BitcoinAdapter) + +// Define your network configurations (see 'networks' option below for details) +const ethMainnet = { id: '1', name: 'Ethereum', chainNamespace: 'eip155', caipNetworkId: 'eip155:1', /* ... */ }; +const solanaMainnet = { id: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', name: 'Solana', chainNamespace: 'solana', /* ... */ }; + +export const appKit = createAppKit({ + projectId: 'YOUR_WALLETCONNECT_PROJECT_ID', + metadata: { /* ... dApp metadata ... */ }, + networks: [ethMainnet, solanaMainnet], // Define all supported networks + adapters: [ // Provide an array of initialized adapters + new EthersAdapter({ /* ... ethers adapter config, e.g., for EVM networks ... */ }), + new SolanaAdapter({ /* ... solana adapter config ... */ }) + ], + // ... other options detailed below +}); -```ts -createAppKit({ projectId, chains, ...options }); +// This appKit instance is then passed to AppKitProvider ``` -## defaultChain +Below are the detailed configuration options you can pass to `createAppKit`: -You can set a desired chain for the initial connection: +## Core Configuration - +### `projectId` +* **Type:** `String` +* **Required:** Yes +* **Description:** Your project ID from [WalletConnect Cloud](https://cloud.walletconnect.com/). This is essential for enabling WalletConnect functionality, which AppKit uses for connecting with a wide range of wallets. - -```ts -import { mainnet } from '@wagmi/core/chains' +```typescript +{ + projectId: 'YOUR_WALLETCONNECT_PROJECT_ID' +} +``` -createAppKit({ -//... -defaultChain: mainnet -}) +### `metadata` +* **Type:** `Object` +* **Required:** Yes +* **Description:** Information about your decentralized application (dApp) that is displayed to users in wallet connection prompts and used for deep linking. + * `name`: (String) The name of your dApp. + * `description`: (String) A brief description of your dApp. + * `url`: (String) The official URL of your dApp. + * `icons`: (Array of Strings) URLs to icon images for your dApp. + * `redirect`: (Object) Configuration for redirecting users back to your app after wallet interactions, especially for mobile wallets. + * `native`: (String) Your app's custom URL scheme for deep linking (e.g., `'yourappscheme://'`). + * `universal`: (String) Your app's universal link URL (e.g., `'https://yourdapp.com/connect'`). + +```typescript +{ + metadata: { + name: 'My Awesome dApp', + description: 'Connecting you to the decentralized web!', + url: 'https://myapp.com', + icons: ['https://myapp.com/logo.png'], + redirect: { + native: 'mydappscheme://', + universal: 'https://myapp.com/walletconnect' // Or your specific universal link path + } + } +} +``` -```` - +### `networks` +* **Type:** `Array` +* **Required:** Yes +* **Description:** An array of network objects that your dApp supports. Each object must conform to the `AppKitNetwork` type, which can be imported: `import type { AppKitNetwork } from '@reown/appkit-common-react-native';`. The full definition can be found in [`packages/common/src/utils/TypeUtil.ts`](https://github.com/reown-com/appkit-react-native/blob/f70c343eb954419ceb43c0cd922a5929d8462a56/packages/common/src/utils/TypeUtil.ts#L30). + AppKit uses the `id` (numeric or string form of chain ID), `chainNamespace` (e.g., 'eip155', 'solana', 'bitcoin'), and `caipNetworkId` (e.g., 'eip155:1', 'solana:mainnet') from these network objects to associate them with the correct adapter. - -```ts -const mainnet = { - chainId: 1, - name: 'Ethereum', - currency: 'ETH', - explorerUrl: 'https://etherscan.io', - rpcUrl: 'https://cloudflare-eth.com', -}; + + If `chainNamespace` is not provided for a network, it will default to `'eip155'`. If `caipNetworkId` is not provided, it will be constructed as `chainNamespace:id`. + Ensure these fields are correctly set for proper adapter mapping, especially for non-EVM chains. + -createAppKit({ - //... - defaultChain: mainnet -}) -```` +**Example Sources for Network Configurations:** - +1. **Pre-exported by AppKit:** For convenience, AppKit exports configurations for some common networks. - -```ts -const mainnet = { - chainId: 1, - name: 'Ethereum', - currency: 'ETH', - explorerUrl: 'https://etherscan.io', - rpcUrl: 'https://cloudflare-eth.com', -}; + ```typescript + import { solana, bitcoin } from '@reown/appkit-react-native'; // Verify exact import path and names -createAppKit({ -//... -defaultChain: mainnet -}) + const configuredNetworks = [solana, bitcoin]; + ``` + *Example of pre-exported Solana network: [packages/appkit/src/networks/solana.ts](https://github.com/reown-com/appkit-react-native/blob/feat/multichain/packages/appkit/src/networks/solana.ts)* -```` - +2. **Using `viem/chains` or `wagmi/chains` for EVM Networks:** You can often use standard chain definitions from libraries like `viem` or `wagmi` directly, as they typically conform to a compatible structure. AppKit will default `chainNamespace` to `'eip155'` for these if not specified. - + ```typescript + import { mainnet as viemMainnet, polygon as viemPolygon } from 'viem/chains'; -## clipboardClient + const configuredNetworks = [viemMainnet, viemPolygon]; + ``` -Use your preferred clipboard library to allow AppKit use the clipboard to copy addresses & URIs +3. **Custom Network Definitions:** You can always define network objects manually. This is necessary for non-EVM chains if not pre-exported, or for custom EVM chains. -```ts -import * as Clipboard from 'expo-clipboard' // or `@react-native-clipboard/clipboard` + ```typescript + import type { AppKitNetwork } from '@reown/appkit-common-react-native'; -createAppKit({ - //... - clipboardClient: { - setString: async (value: string) => { - await Clipboard.setStringAsync(value) - } - } -}) -```` + const myCustomSolanaDevnet: AppKitNetwork = { + id: 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1', + name: 'Solana Devnet', + chainNamespace: 'solana', + caipNetworkId: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1', + nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 }, + rpcUrls: { + default: { http: ['https://rpc.walletconnect.org/v1'] } + }, + blockExplorers: { + default: { name: 'Solscan', url: 'https://solscan.io' } + }, + testnet: true + }; + + const configuredNetworks = [myCustomSolanaDevnet]; + ``` + +**Final Configuration Example:** + +```typescript +{ + networks: configuredNetworks // Use one of the methods above to define this array +} +``` + +### `adapters` +* **Type:** `Array` +* **Required:** Yes +* **Description:** An array of initialized chain adapter instances. Each adapter is responsible for handling a specific blockchain namespace (e.g., 'eip155' for EVM chains, 'solana' for Solana). AppKit will map the networks provided in the `networks` option to the appropriate adapter based on the namespace derived from the network's `id` and the namespaces supported by each adapter. + +```typescript +import { EthersAdapter } from '@reown/appkit-ethers-react-native'; +import { SolanaAdapter } from '@reown/appkit-solana-react-native'; +// import { BitcoinAdapter } from '@reown/appkit-bitcoin-react-native'; + +const projectId = 'YOUR_WALLETCONNECT_PROJECT_ID'; // Assuming projectId is defined + +{ + adapters: [ + new EthersAdapter({ projectId }), + new SolanaAdapter({ projectId }), + // new BitcoinAdapter({ projectId /* ... other bitcoin adapter config ... */ }) + ] +} +``` -## customWallets +### `defaultNetwork` +* **Type:** `AppKitNetwork` (Optional) +* **Description:** The network that AppKit should attempt to connect to by default, or highlight initially if no prior session exists. This object must be one of the networks defined in your `networks` array. -Add custom wallets to the modal's main view. `customWallets` is an array of objects, where each object contains specific information of a custom wallet. +```typescript +{ + // Assuming ethereumMainnet is a valid AppKitNetwork object defined in your 'networks' array + defaultNetwork: ethereumMainnet +} +``` -```ts -createAppKit({ - //... +## Modal & Wallet Display Customization + +### `customWallets` +* **Type:** `Array` (Optional) +* **Description:** Allows you to add custom wallet entries to the connection modal. Each object in the array defines a wallet not available through WalletConnect's default registry. Refer to `WalletEntry` type for exact properties. + +```typescript +{ customWallets: [ { id: "myCustomWallet", @@ -100,163 +183,170 @@ createAppKit({ app_store: "app_store", // Optional play_store: "play_store", // Optional }, - ], -}); + ] +} ``` -## featuredWalletIds +### `featuredWalletIds` +* **Type:** `Array` (Optional) +* **Description:** Select wallets that are going to be shown on the modal's main view. Array of wallet IDs defined will be prioritized (order is respected). These wallets will also show up first in `All Wallets` view. You can find the wallets ids in [WalletGuide](https://walletguide.walletconnect.network/). -Select wallets that are going to be shown on the modal's main view. Array of wallet IDs defined will be prioritized (order is respected). -These wallets will also show up first in `All Wallets` view. -You can find the wallets ids in [WalletGuide](https://walletguide.walletconnect.network/) - -```ts -createAppKit({ - //... +```ts +// Within createAppKit call +{ featuredWalletIds: [ "1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369", // Rainbow "4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0", // Trust - ], -}); + ] +} ``` -## includeWalletIds - -Override default recommended wallets that are fetched from [WalletGuide](https://walletguide.walletconnect.network/). -Array of wallet ids defined will be shown (order is respected). -Unlike `featuredWalletIds`, these wallets will be the **only** ones shown in `All Wallets` view and as recommended wallets. -You can get these ids from the explorer link mentioned before by clicking on a copy icon of desired wallet card. +### `includeWalletIds` +* **Type:** `Array` (Optional) +* **Description:** If provided, only wallets whose IDs are in this array will be shown in the modal. This effectively creates an allowlist, overriding the default WalletConnect registry listings. -```ts -createAppKit({ - //... +```typescript +{ includeWalletIds: [ - "1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369", // Rainbow - "4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0", // Trust - ], -}); + "c57ca95b47569778a828d19178114f2db125b25b778adf5cba72bd778e231769", // Example: MetaMask + // ... only include these wallets + ] +} ``` -## excludeWalletIds +### `excludeWalletIds` +* **Type:** `Array` (Optional) +* **Description:** An array of wallet IDs to be hidden from the modal. This allows you to remove specific wallets from the default WalletConnect registry listings. -Exclude wallets that are fetched from [WalletGuide](https://walletguide.walletconnect.network/). -Array of wallet ids defined will be excluded. -All other wallets will be shown in respective places. -You can find the wallets IDs in our [Wallets List](/cloud/wallets/wallet-list). - -```ts -createAppKit({ - //... +```typescript +{ excludeWalletIds: [ - "4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0", // Trust - "fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa", // Coinbase - ], -}); + "fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa", // Example: Coinbase Wallet (if you wish to exclude it) + ] +} ``` -## debug +## Theming & UI Customization -Enable or disable debug mode in your AppKit. This is useful if you want to see UI alerts when debugging. Default is `false`. +### `themeMode` +* **Type:** `'light' | 'dark'` (Optional) +* **Description:** Sets the initial theme for the AppKit modal. Defaults to the system theme or 'light' if system theme is unavailable. -```ts -createAppKit({ - //... - debug: true, -}); +```typescript +{ + themeMode: 'dark' +} ``` -## features - -Allows you to toggle (enable or disable) additional features provided by AppKit. Features such as email and social logins, swaps, etc., can be enabled using this parameter. +### `themeVariables` +* **Type:** `Object` (Optional) +* **Description:** Allows you to customize the accent color of the AppKit modal. Refer to the Theming documentation for details. -### swaps +```typescript +{ + themeVariables: { + 'accent': '#4E88F7' + } +} +``` -Enable or disable the swap feature in your AppKit. [Swaps](/appkit/react/transactions/swaps) feature is enabled by default. +### `networkImages` (Formerly `chainImages`) +* **Type:** `Record` (Optional) +* **Description:** An object to provide custom image URLs for network icons in the modal. Keys should be network IDs (e.g., 'eip155:1', 'solana:mainnet'). -```ts -createAppKit({ - //... - features: { - swaps: true, - }, -}); +```typescript +{ + networkImages: { + 'eip155:1': 'https://example.com/images/ethereum.png', + 'solana:mainnet': 'https://example.com/images/solana.png' + } +} ``` -### email +## Token Balance Configuration -This boolean defines whether you want to enable email login. This feature is enabled by default. +### `tokens` +* **Type:** `Record` (Optional) +* **Description:** An object to configure specific tokens for which AppKit should display balances. The keys are CAIP-2 network IDs (e.g., 'eip155:1' for Ethereum Mainnet, 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1' for a specific Solana network instance if required by ID structure). The value for each network ID is an object containing the token's contract `address` on that network. -```ts -createAppKit({ - //... - features: { - email: true, - }, -}); +```typescript +{ + tokens: { + 'eip155:1': { // Ethereum Mainnet + address: '0xdAC17F958D2ee523a2206206994597C13D831ec7' // USDT on Ethereum + }, + 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': { // Solana Mainnet + address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // USDC on Solana + } + // Add other tokens for other configured networks as needed + } +} ``` -### socials +## Utility & Advanced Options -This array contains the list of social platforms that you want to enable for user authentication. The platforms supported are X, Discord and Apple. The default value of undefined displays everything. Set it to false to disable this feature. You can also pass an empty array to disable it. +### `clipboardClient` +* **Type:** `Object` +* **Required:** No (but functionally required for copy features) +* **Description:** Allows you to provide your own clipboard implementation. **If this client is not provided, all UI elements within AppKit that offer a "copy to clipboard" functionality (e.g., for addresses, QR code URIs) will be hidden.** To enable copy features, you must supply this client. + It requires an async `setString` method that takes a string value to be copied. -```ts -createAppKit({ - //... - features: { - socials: ["x", "discord", "apple"], - }, -}); -``` +```typescript +import * as Clipboard from 'expo-clipboard'; // or from '@react-native-clipboard/clipboard' -### emailShowWallets +{ + clipboardClient: { + setString: async (value: string) => { + await Clipboard.setStringAsync(value); + // Optionally, add user feedback e.g., a toast message + // console.log('Copied to clipboard!'); + } + } +} +``` -This boolean defines whether you want to show the wallet options on the first connect screen. If this is false and socials are enabled, it will show a button that directs you to a new screen displaying the wallet options. This feature is enabled by default. +### `enableAnalytics` +* **Type:** `boolean` (Optional) +* **Default:** `true` +* **Description:** Set to `true` to enable analytics and gather insights on user activity within your [Reown Cloud dashboard](https://cloud.reown.com). -```ts -createAppKit({ - //... - features: { - emailShowWallets: false, - }, -}); +```typescript +{ + enableAnalytics: true +} ``` -## enableAnalytics +### `debug` +* **Type:** `boolean` (Optional) +* **Default:** `false` +* **Description:** Set to `true` to enable debug mode. This may show additional UI alerts or console logs helpful for development and troubleshooting. -Enable analytics to get more insights on your users activity within your [Reown Cloud's dashboard](https://cloud.reown.com) - -```ts -createAppKit({ - //... - enableAnalytics: true, -}); +```typescript +{ + debug: true +} ``` - +## Feature Flags -## chainImages +### `features` +* **Type:** `Object` (Optional) +* **Description:** An object to toggle additional AppKit features on or off. -Add or override the modal's network images. + * `swaps`: (Boolean, Optional) Enable/disable the token swap feature. Default: `true` (Verify default). + * `email`: (Boolean, Optional) Enable/disable email-based login/wallet functionality. Default: `true` (Verify default). + * `socials`: (Array of Strings or Boolean, Optional) Configure social login options. Provide an array like `["x", "discord", "apple"]` to enable specific platforms. Set to `false` or an empty array `[]` to disable all social logins. Default: All available socials enabled (Verify default). + * `emailShowWallets`: (Boolean, Optional) If `email` login is enabled, this controls whether wallet options are shown on the initial connect screen alongside email. If `false` and socials are also enabled, a button might direct to a separate screen for wallet options. Default: `true` (Verify default). -```ts -createAppKit({ - // ... - chainImages: { - 1: "https://my.images.com/eth.png", - }, -}); +```typescript +{ + features: { + swaps: false, // Disable swaps + email: true, + socials: ["x", "discord"], // Only enable X and Discord + emailShowWallets: true + } +} ``` -## connectorImages - -Set or override the images of any connector. - -```ts -createAppKit({ - connectorImages: { - coinbaseWallet: "https://images.mydapp.com/coinbase.png", - walletConnect: "https://images.mydapp.com/walletconnect.png", - appKitAuth: "https://images.mydapp.com/auth.png", - }, -}); -``` +*This list may not be exhaustive. Always refer to the arguments of the `createAppKit` function and associated type definitions in the source code for the most up-to-date and complete list of options and their structures.* diff --git a/docs.json b/docs.json index a680b8975..83ec1cae5 100644 --- a/docs.json +++ b/docs.json @@ -638,10 +638,6 @@ "appkit/react-native/core/options", "appkit/react-native/core/hooks", "appkit/react-native/core/components", - "appkit/react-native/core/email", - "appkit/react-native/core/smart-accounts", - "appkit/react-native/core/siwe", - "appkit/react-native/core/link-mode", "appkit/react-native/core/theming", "appkit/react-native/core/resources" ] From e6694def8c2a8d931ff5a568b0b8b01d78a5942a Mon Sep 17 00:00:00 2001 From: nacho <25931366+ignaciosantise@users.noreply.github.com> Date: Tue, 20 May 2025 15:10:13 -0300 Subject: [PATCH 2/7] chore: added migration guide --- .../core/migration-multichain.mdx | 342 ++++++++++++++++++ appkit/react-native/core/options.mdx | 2 +- docs.json | 3 +- 3 files changed, 345 insertions(+), 2 deletions(-) create mode 100644 appkit/react-native/core/migration-multichain.mdx diff --git a/appkit/react-native/core/migration-multichain.mdx b/appkit/react-native/core/migration-multichain.mdx new file mode 100644 index 000000000..c44bdaea2 --- /dev/null +++ b/appkit/react-native/core/migration-multichain.mdx @@ -0,0 +1,342 @@ +--- +title: Migrate to Multichain +description: A guide to help you migrate your existing Reown AppKit React Native integration to the new multichain version. +--- + +import { Card, CardGroup } from '@mintlify/components'; + +This guide will walk you through the necessary steps to update your existing Reown AppKit React Native integration to the latest multichain version. The new version introduces a more flexible and powerful architecture, centered around a core AppKit library and distinct chain-specific adapters. + +For a deeper understanding of the new architecture, please review the [Architecture](./architecture) page. + +## Key Changes at a Glance + +Before diving into the specific steps, here's a high-level overview of the most significant changes: + +- **Core Library & Adapters:** Instead of using monolithic, EVM-specific packages like `@reown/appkit-wagmi-react-native` or `@reown/appkit-ethers-react-native` as your primary entry point, you will now use a core package `@reown/appkit-react-native`. Chain-specific logic for EVM (Ethers, Wagmi), Solana, Bitcoin, and potentially other chains is handled by separate, installable adapter packages (e.g., `@reown/appkit-ethers-react-native`, `@reown/appkit-solana-react-native`). +- **Centralized Logic:** The new `appkit` instance (initialized via `createAppKit`) becomes the central hub for managing connections, adapters, and events across multiple chains. +- **Unified Hooks & Components:** Hooks and UI components are now consistently imported from the core `@reown/appkit-react-native` package. + +## 1. Dependency Updates + +Your first step is to update your project's dependencies. + +### a. Remove Old Packages (If Applicable) +If you were previously using older, specific AppKit packages like `@web3modal/*` or potentially differently named predecessors to `@reown/appkit-*-react-native`, you should remove them. The primary packages to focus on now are `@reown/appkit-react-native` and the new chain adapters. + +### b. Install Core Package & Polyfills/Helpers +Install the main AppKit library along with essential peer dependencies for React Native: + +```bash +# For Expo projects +npx expo install @reown/appkit-react-native @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat expo-application + +# For React Native CLI projects +npm install @reown/appkit-react-native @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat +# or +yarn add @reown/appkit-react-native @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat +``` +Then, for iOS in React Native CLI projects: +```bash +npx pod-install +``` + +### c. Install Chain Adapter Packages +Based on the blockchains your dApp needs to support, install the corresponding adapter packages. Here are the primary ones: + +- **EVM (Ethers):** + ```bash + # For Expo + npx expo install @reown/appkit-ethers-react-native + # For RN CLI + # npm install @reown/appkit-ethers-react-native + # yarn add @reown/appkit-ethers-react-native + ``` +- **EVM (Wagmi):** + ```bash + # For Expo + npx expo install @reown/appkit-wagmi-react-native wagmi viem@2.x @tanstack/react-query + # For RN CLI + # npm install @reown/appkit-wagmi-react-native wagmi viem@2.x @tanstack/react-query + # yarn add @reown/appkit-wagmi-react-native wagmi viem@2.x @tanstack/react-query + ``` +- **Solana:** + ```bash + # For Expo + npx expo install @reown/appkit-solana-react-native + # For RN CLI + # npm install @reown/appkit-solana-react-native + # yarn add @reown/appkit-solana-react-native + ``` +- **Bitcoin:** + ```bash + # For Expo + npx expo install @reown/appkit-bitcoin-react-native + # For RN CLI + # npm install @reown/appkit-bitcoin-react-native + # yarn add @reown/appkit-bitcoin-react-native + ``` + + +The package names for adapters like `@reown/appkit-ethers-react-native` and `@reown/appkit-wagmi-react-native` are the same as some older, more monolithic packages. The key difference is how they are used (as pluggable adapters into the core `@reown/appkit-react-native`). + + +## 2. Crucial Polyfill Import + +To ensure proper functioning, especially for WalletConnect features within React Native, the `@walletconnect/react-native-compat` package must be imported at the very beginning of your application's entry point or your AppKit configuration file. + +```typescript +// App.tsx or your AppKitConfig.ts +import "@walletconnect/react-native-compat"; // MUST BE THE VERY FIRST IMPORT + +// ... other imports like React, createAppKit, adapters, etc. +``` + +This step is critical for avoiding runtime errors related to missing polyfills. + +## 3. AppKit Initialization (`createAppKit`) + +The way you initialize AppKit has changed significantly to support the new adapter-based architecture. + +### Old Method (Example from docs.reown.com using Wagmi) + +Previously, for an EVM setup with Wagmi, you might have done something like this (based on the `docs.reown.com` structure): + +```typescript +// Old approach (example) +// import { createAppKit, defaultWagmiConfig } from "@reown/appkit-wagmi-react-native"; // Path might vary +// import { mainnet, polygon } from "@wagmi/core/chains"; // Path might vary + +// const projectId = "YOUR_PROJECT_ID"; +// const metadata = { /* ... */ }; +// const chains = [mainnet, polygon]; + +// const wagmiConfig = defaultWagmiConfig({ chains, projectId, metadata }); + +// const appKitInstance = createAppKit({ // createAppKit might have been named differently or part of the adapter pkg +// wagmiConfig, +// projectId, +// metadata, +// chains, // This 'chains' prop might have been for AppKit's own chain display logic +// // ... other options +// }); +``` + +### New Multichain Method + +With the new version, you initialize adapters first and then pass them to `createAppKit` from the core `@reown/appkit-react-native` package. + +```typescript +// New approach: src/AppKitConfig.ts (or your preferred file) +import "@walletconnect/react-native-compat"; // Ensure this is the first import + +import { createAppKit, type AppKitNetwork } from "@reown/appkit-react-native"; +import { EthersAdapter } from "@reown/appkit-ethers-react-native"; +import { SolanaAdapter } from "@reown/appkit-solana-react-native"; +import { BitcoinAdapter } from "@reown/appkit-bitcoin-react-native"; +import { WagmiAdapter } from "@reown/appkit-wagmi-react-native"; + +// Import chain definitions (examples) +import { mainnet as viemMainnet, polygon as viemPolygon } from "viem/chains"; // For EVM +import { solana, bitcoin } from "@reown/appkit-react-native"; // Pre-defined AppKitNetwork objects + +const projectId = "YOUR_PROJECT_ID"; // Obtain from Reown Cloud + +const metadata = { + name: "My Awesome Multi-Chain dApp", + description: "My dApp supporting multiple blockchains!", + url: "https://myapp.com", + icons: ["https://myapp.com/icon.png"], + redirect: { + native: "YOUR_APP_SCHEME://", // e.g., "myapp://" + universal: "YOUR_APP_UNIVERSAL_LINK.com", // e.g., "https://myapp.com/connect" + }, +}; + +// 1. Define your AppKitNetworks (for AppKit's UI and network management) +// These can come from viem/chains (for EVM) or be custom AppKitNetwork objects. +const appNetworks: AppKitNetwork[] = [ + viemMainnet, // viem chains are automatically compatible as AppKitNetwork for 'eip155' + viemPolygon, + solana, // Pre-defined AppKit solana network + bitcoin, // Pre-defined AppKit bitcoin network + // You can also define custom AppKitNetwork objects here +]; + +// 2. Initialize Adapters for the chains you want to support +// For EVM chains, choose ONE of the following adapters (EthersAdapter or WagmiAdapter): + +// Option A: EthersAdapter for general EVM support +const ethersAdapter = new EthersAdapter({ projectId }); + +// Option B: WagmiAdapter if you are using Wagmi for EVM state management +const wagmiEvmNetworks = [viemMainnet, viemPolygon]; // Subset of appNetworks or specific Wagmi chains +const wagmiAdapter = new WagmiAdapter({ + projectId, + networks: wagmiEvmNetworks, // These are Wagmi/viem chain objects +}); + +// Initialize adapters for other chains as needed +const solanaAdapter = new SolanaAdapter({ projectId }); +const bitcoinAdapter = new BitcoinAdapter({ projectId }); + +// 3. Create the AppKit instance +// In this example, we'll use EthersAdapter for EVM chains. +// If you chose WagmiAdapter, replace ethersAdapter with wagmiAdapter below. +export const appKit = createAppKit({ + projectId, + metadata, + networks: appNetworks, // Master list of networks for AppKit UI and context + adapters: [ + ethersAdapter, // Handles EVM chains defined in 'networks' + // wagmiAdapter, // Or use this if you chose Wagmi for EVM + solanaAdapter, // Handles Solana chains + bitcoinAdapter, // Handles Bitcoin chains + ], + // Optional: specify a default network from your 'networks' list + // defaultNetwork: viemMainnet, + // ... other AppKit options (see Options page) +}); +``` + +**Key differences in initialization:** +- `createAppKit` is imported from `@reown/appkit-react-native`. +- You explicitly create instances of the adapters you need (e.g., `new EthersAdapter(...)`, `new WagmiAdapter(...)`). +- The `adapters` array in `createAppKit` takes these initialized adapter instances. +- The `networks` array in `createAppKit` takes `AppKitNetwork` objects, which define all supported networks for AppKit's UI and context. `viem/chains` objects can be directly used for EVM networks. +- For the `WagmiAdapter`, the `networks` property in its constructor defines which EVM chains *it* will specifically manage using Wagmi. + +## 4. Provider Setup + +The way you set up providers in your `App.tsx` (or equivalent root file) has minor adjustments, especially if you are using Wagmi. + +### a. `AppKitProvider` +You will now need to wrap your application (or the relevant part) with `AppKitProvider` from `@reown/appkit-react-native`. This provider makes the AppKit instance, created in the previous step, available to all child components and hooks. + +```tsx +// App.tsx +import React from 'react'; +import { AppKitProvider } from '@reown/appkit-react-native'; +import { appKit } from './AppKitConfig'; // Your configured AppKit instance +import YourAppRootComponent from './YourAppRootComponent'; // Or your main app layout + +function App() { + return ( + + + + ); +} +export default App; +``` + +### b. Wagmi Specific Providers (`WagmiProvider`, `QueryClientProvider`) +If you're using the `WagmiAdapter`, you still need to set up `WagmiProvider` (from `wagmi`) and `QueryClientProvider` (from `@tanstack/react-query`) as you did before. The primary change is that the `config` prop for `WagmiProvider` now comes directly from your initialized `WagmiAdapter` instance's `wagmiConfig` property. + +```tsx +// App.tsx (if using WagmiAdapter) +import React from 'react'; +import { AppKitProvider } from '@reown/appkit-react-native'; +import { appKit, wagmiAdapter } from './AppKitConfig'; +import YourAppRootComponent from './YourAppRootComponent'; + +import { WagmiProvider } from 'wagmi'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; + +const queryClient = new QueryClient(); + +function App() { + return ( + + + + + + + + ); +} +export default App; +``` + +### c. Rendering AppKit UI +Ensure the `` component (imported from `@reown/appkit-react-native`) is included in your app's component tree, typically in your root component, to render the modal UI. This was likely already in place. + +```tsx +// YourAppRootComponent.tsx (Simplified) +import React from 'react'; +import { AppKit } from '@reown/appkit-react-native'; +// ... your other components ... + +function YourAppRootComponent() { + return ( + <> + {/* Your app's content */} + {/* ... e.g., ConnectButton, etc. ... */} + + {/* This renders the modal and other AppKit UI */} + + ); +} +export default YourAppRootComponent; +``` + +## 5. Configuration Options (`createAppKit` parameters) + +Many configuration options previously passed to `createAppKit` (or `defaultConfig`/`defaultWagmiConfig`) are still available but are now part of the single `createAppKit` call from `@reown/appkit-react-native`. +- **`networks`**: As described above, an array of `AppKitNetwork` objects. +- **`adapters`**: As described, an array of initialized adapter instances. +- **`defaultNetwork`**: (Formerly `defaultChain`). +- **`networkImages`**: (Formerly `chainImages`). +- **`tokens`**: New property (`Record`) for displaying token balances. + +Refer to the [Options](./options) documentation for the complete and up-to-date list of configuration parameters. + +## 6. Hooks Migration + +All AppKit hooks are now imported directly from `@reown/appkit-react-native`. + +- **`useAppKit()`**: + - Import from `@reown/appkit-react-native`. + - Still the primary hook for modal control (`open`, `close`, `isOpen`). + - Now also includes actions like `disconnect` and `switchNetwork`. +- **`useAccount()`**: + - Import from `@reown/appkit-react-native`. + - Provides `address`, `chainId`, `isConnected`, and potentially other multichain-aware details. Functionality is largely the same; primary change is the import path and potentially more multichain-aware return values. +- **`useProvider()` (New Hook)**: + - Import from `@reown/appkit-react-native`. + - Use this to get the underlying chain-specific provider/client (e.g., Ethers provider, Wagmi client, Solana connection). + - Can be called with a namespace (e.g., `'eip155'`, `'solana'`) to get a provider for a specific chain type if multiple are connected or configured. +- **`useAppKitEventSubscription()` (New Hook)**: + - Import from `@reown/appkit-react-native`. + - Allows subscription to various AppKit lifecycle events. +- **Deprecated Hooks:** + - `useAppKitState`: Its functionality is largely covered by `useAccount`, `useAppKit`, and other more specific hooks. Review your usage and map to the new hooks. + - `useDisconnect`: The `disconnect` function is now available from `useAppKit().disconnect()`. + +Review the [Hooks](./hooks) documentation for detailed API information. + +## 7. Components Migration + +Update all UI component imports to use `@reown/appkit-react-native`. Key components include: + +- `` +- `` +- `` +- `` +- `` + +Their core functionality and props remain largely the same as before, but ensure you're importing them from the new unified package. Refer to the [Components](./components) documentation for details on props if needed. + +## Summary of Key Actions + +1. **Update Dependencies:** Switch to `@reown/appkit-react-native` and add new adapter packages. +2. **Ensure Polyfill:** Add `import "@walletconnect/react-native-compat";` as the very first import. +3. **Revamp Initialization:** Use the new `createAppKit` signature with `networks` and `adapters` arrays. +4. **Adjust Provider Setup:** Set up `AppKitProvider`. For Wagmi, use `wagmiAdapter.wagmiConfig` for `WagmiProvider`. +5. **Update Hook Imports:** Change all hook imports to `@reown/appkit-react-native` and adapt to API changes (e.g., `useDisconnect` -> `useAppKit().disconnect`, new hooks like `useProvider`). +6. **Update Component Imports:** Change all component imports to `@reown/appkit-react-native`. +7. **Add ``:** Ensure this component is rendered for the modal UI. +8. **Review Options:** Check your `createAppKit` options against the new [Options](./options) documentation. + +This migration involves some significant structural changes, but the result is a more robust and flexible system for building multichain React Native applications. If you encounter issues, refer to the main documentation pages or seek support. \ No newline at end of file diff --git a/appkit/react-native/core/options.mdx b/appkit/react-native/core/options.mdx index c14bf3868..02fd23459 100644 --- a/appkit/react-native/core/options.mdx +++ b/appkit/react-native/core/options.mdx @@ -267,7 +267,7 @@ const projectId = 'YOUR_WALLETCONNECT_PROJECT_ID'; // Assuming projectId is defi ### `tokens` * **Type:** `Record` (Optional) -* **Description:** An object to configure specific tokens for which AppKit should display balances. The keys are CAIP-2 network IDs (e.g., 'eip155:1' for Ethereum Mainnet, 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1' for a specific Solana network instance if required by ID structure). The value for each network ID is an object containing the token's contract `address` on that network. +* **Description:** An object to configure specific tokens for which AppKit should display balances. The keys are CAIP-2 network IDs (e.g., 'eip155:1' for Ethereum Mainnet for a specific Solana network instance if required by ID structure). The value for each network ID is an object containing the token's contract `address` on that network. ```typescript { diff --git a/docs.json b/docs.json index 83ec1cae5..f5dbafc52 100644 --- a/docs.json +++ b/docs.json @@ -639,7 +639,8 @@ "appkit/react-native/core/hooks", "appkit/react-native/core/components", "appkit/react-native/core/theming", - "appkit/react-native/core/resources" + "appkit/react-native/core/resources", + "appkit/react-native/core/migration-multichain" ] }, { From 93067f0a7ddc56c2d41293f7c4ba8ddcb6a71d93 Mon Sep 17 00:00:00 2001 From: nacho <25931366+ignaciosantise@users.noreply.github.com> Date: Tue, 20 May 2025 17:46:48 -0300 Subject: [PATCH 3/7] chore: added alpha tags to new packages --- appkit/react-native/core/installation.mdx | 12 ++++---- .../core/migration-multichain.mdx | 30 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/appkit/react-native/core/installation.mdx b/appkit/react-native/core/installation.mdx index 9cfcc1af6..92c31d6e0 100644 --- a/appkit/react-native/core/installation.mdx +++ b/appkit/react-native/core/installation.mdx @@ -22,7 +22,7 @@ Installation is a two-step process: ### Core Library ```bash -npx expo install @reown/appkit-react-native @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat expo-application +npx expo install @reown/appkit-react-native@alpha @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat expo-application ``` @@ -33,7 +33,7 @@ npx expo install @reown/appkit-react-native @react-native-async-storage/async-st Install our core library and it's dependencies ```bash -npm install @reown/appkit-react-native @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat +npm install @reown/appkit-react-native@alpha @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat ``` On iOS, use CocoaPods to add the native modules to your project: @@ -58,7 +58,7 @@ Install the adapters for the chains you intend to support:

This adapter uses Ethers.js for interacting with EVM chains.

```bash - npx expo install @reown/appkit-ethers-react-native + npx expo install @reown/appkit-ethers-react-native@alpha ```

To initialize the Ethers adapter:

```typescript @@ -75,7 +75,7 @@ Install the adapters for the chains you intend to support:

First, install the Reown Wagmi adapter and its peer dependencies:

```bash # Install the Reown Wagmi adapter - npx expo install @reown/appkit-wagmi-react-native + npx expo install @reown/appkit-wagmi-react-native@alpha # Install Wagmi and its required peer dependencies npx expo install wagmi viem@2.x @tanstack/react-query @@ -147,7 +147,7 @@ Install the adapters for the chains you intend to support:

For Solana, install the Solana adapter:

```bash - npx expo install @reown/appkit-solana-react-native + npx expo install @reown/appkit-solana-react-native@alpha ```

To initialize the Solana adapter:

```typescript @@ -160,7 +160,7 @@ Install the adapters for the chains you intend to support:

For Bitcoin, install the Bitcoin adapter:

```bash - npx expo install @reown/appkit-bitcoin-react-native + npx expo install @reown/appkit-bitcoin-react-native@alpha ```

To initialize the Bitcoin adapter:

```typescript diff --git a/appkit/react-native/core/migration-multichain.mdx b/appkit/react-native/core/migration-multichain.mdx index c44bdaea2..9ebeed778 100644 --- a/appkit/react-native/core/migration-multichain.mdx +++ b/appkit/react-native/core/migration-multichain.mdx @@ -29,12 +29,12 @@ Install the main AppKit library along with essential peer dependencies for React ```bash # For Expo projects -npx expo install @reown/appkit-react-native @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat expo-application +npx expo install @reown/appkit-react-native@alpha @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat expo-application # For React Native CLI projects -npm install @reown/appkit-react-native @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat +npm install @reown/appkit-react-native@alpha @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat # or -yarn add @reown/appkit-react-native @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat +yarn add @reown/appkit-react-native@alpha @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat ``` Then, for iOS in React Native CLI projects: ```bash @@ -47,34 +47,34 @@ Based on the blockchains your dApp needs to support, install the corresponding a - **EVM (Ethers):** ```bash # For Expo - npx expo install @reown/appkit-ethers-react-native + npx expo install @reown/appkit-ethers-react-native@alpha # For RN CLI - # npm install @reown/appkit-ethers-react-native - # yarn add @reown/appkit-ethers-react-native + # npm install @reown/appkit-ethers-react-native@alpha + # yarn add @reown/appkit-ethers-react-native@alpha ``` - **EVM (Wagmi):** ```bash # For Expo - npx expo install @reown/appkit-wagmi-react-native wagmi viem@2.x @tanstack/react-query + npx expo install @reown/appkit-wagmi-react-native@alpha wagmi viem@2.x @tanstack/react-query # For RN CLI - # npm install @reown/appkit-wagmi-react-native wagmi viem@2.x @tanstack/react-query - # yarn add @reown/appkit-wagmi-react-native wagmi viem@2.x @tanstack/react-query + # npm install @reown/appkit-wagmi-react-native@alpha wagmi viem@2.x @tanstack/react-query + # yarn add @reown/appkit-wagmi-react-native@alpha wagmi viem@2.x @tanstack/react-query ``` - **Solana:** ```bash # For Expo - npx expo install @reown/appkit-solana-react-native + npx expo install @reown/appkit-solana-react-native@alpha # For RN CLI - # npm install @reown/appkit-solana-react-native - # yarn add @reown/appkit-solana-react-native + # npm install @reown/appkit-solana-react-native@alpha + # yarn add @reown/appkit-solana-react-native@alpha ``` - **Bitcoin:** ```bash # For Expo - npx expo install @reown/appkit-bitcoin-react-native + npx expo install @reown/appkit-bitcoin-react-native@alpha # For RN CLI - # npm install @reown/appkit-bitcoin-react-native - # yarn add @reown/appkit-bitcoin-react-native + # npm install @reown/appkit-bitcoin-react-native@alpha + # yarn add @reown/appkit-bitcoin-react-native@alpha ``` From fa29b59b8556b1b36336009d47d91dc3325ef456 Mon Sep 17 00:00:00 2001 From: nacho <25931366+ignaciosantise@users.noreply.github.com> Date: Tue, 10 Jun 2025 12:28:54 -0300 Subject: [PATCH 4/7] chore: added storage & phantom support --- appkit/react-native/core/installation.mdx | 61 ++++++++++++++++++++--- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/appkit/react-native/core/installation.mdx b/appkit/react-native/core/installation.mdx index 92c31d6e0..545b5c1ed 100644 --- a/appkit/react-native/core/installation.mdx +++ b/appkit/react-native/core/installation.mdx @@ -305,12 +305,6 @@ export default ConnectButton; ``` For detailed examples on specific actions like signing messages, sending transactions, or switching networks, please refer to the [Hooks](./hooks#useprovider) and [Examples](#examples) sections. -## Getting Support ๐Ÿ™‹ - -Reown is committed to delivering the best developer experience. - -If you have any questions, feature requests, or bug reports, feel free to open an issue on [GitHub](https://github.com/reown-com/appkit-react-native) - ## Enable Wallet Detection @@ -471,6 +465,56 @@ Example:
+## Enable Phantom Wallet + +Phantom Wallet is a popular wallet on the Solana blockchain. Because it uses a custom connection protocol, it requires a specific connector to be added to your AppKit configuration. + +To enable Phantom Wallet, you'll need to import the `PhantomConnector` from `@reown/appkit-solana-react-native` and add it to the `extraConnectors` array in your `createAppKit` configuration. + +Here's how to update your `AppKitConfig.ts` file, using the example from the [Implementation](#1-initialize-appkit) section as a base: + +```typescript {5,30-32} +// src/AppKitConfig.ts (or wherever you prefer to configure it) +import "@walletconnect/react-native-compat"; +import { createAppKit, bitcoin, solana, type AppKitNetwork } from '@reown/appkit-react-native'; +import { EthersAdapter } from '@reown/appkit-ethers-react-native'; +import { SolanaAdapter, PhantomConnector } from '@reown/appkit-solana-react-native'; +import { BitcoinAdapter } from '@reown/appkit-bitcoin-react-native'; + +// You can use 'viem/chains' or define your own chains using `AppKitNetwork` type. Check Options/networks for more detailed info +import { mainnet, polygon } from 'viem/chains'; + +const projectId = 'YOUR_PROJECT_ID'; // Obtain from Cloud + +const ethersAdapter = new EthersAdapter({ + projectId +}); + +const solanaAdapter = new SolanaAdapter({ + projectId +}); + +const bitcoinAdapter = new BitcoinAdapter({ + projectId +}); + +export const appKit = createAppKit({ + projectId, + networks: [mainnet, polygon, solana, bitcoin], + defaultNetwork: mainnet, // Optional: set a default network + adapters: [ethersAdapter, solanaAdapter, bitcoinAdapter], + extraConnectors: [ + new PhantomConnector({ cluster: 'mainnet-beta' }) // Or 'devnet', 'testnet' + ], + // Other AppKit options (e.g., metadata for your dApp) +}); +``` + + +The `cluster` option in `PhantomConnector` can be set to `'mainnet-beta'`, `'devnet'`, or `'testnet'` depending on which Solana cluster you want to connect to. + + + ## Examples @@ -514,3 +558,8 @@ Want to see AppKit in action? Download our sample AppKit apps below and explore - [Android Build (Firebase)](https://appdistribution.firebase.google.com/pub/i/0297fbd3de8f1e3f) - [iOS Build (Testflight)](https://testflight.apple.com/join/YW2jD2s0) +## Getting Support ๐Ÿ™‹ + +Reown is committed to delivering the best developer experience. + +If you have any questions, feature requests, or bug reports, feel free to open an issue on [GitHub](https://github.com/reown-com/appkit-react-native) \ No newline at end of file From 3ce7470df92a140655bb254d0c2e602ba0e24048 Mon Sep 17 00:00:00 2001 From: nacho <25931366+ignaciosantise@users.noreply.github.com> Date: Tue, 10 Jun 2025 12:29:21 -0300 Subject: [PATCH 5/7] chore: added storage config --- appkit/react-native/core/installation.mdx | 135 +++++++++++++++++++++- 1 file changed, 133 insertions(+), 2 deletions(-) diff --git a/appkit/react-native/core/installation.mdx b/appkit/react-native/core/installation.mdx index 545b5c1ed..a30903fc5 100644 --- a/appkit/react-native/core/installation.mdx +++ b/appkit/react-native/core/installation.mdx @@ -231,7 +231,7 @@ export const appKit = createAppKit({ Wrap your application with the `AppKitProvider` to make the `AppKit` instance available throughout your component tree via context. -```tsx +```tsx {3,9} // App.tsx import React from 'react'; import { AppKitProvider } from '@reown/appkit-react-native'; @@ -253,7 +253,7 @@ export default App; To display the AppKit modal and other potential UI elements, you need to include the `` component in your application. If you want the modal to be accessible from anywhere in your app, it's best to place this component within your main application root component (e.g., the `YourAppRootComponent` from the example above, or directly in `App.tsx` if it serves as your main layout). -```tsx +```tsx {3,15} // YourAppRootComponent.tsx (or App.tsx if it contains your main layout) import React from 'react'; import { AppKit } from '@reown/appkit-react-native'; @@ -305,6 +305,137 @@ export default ConnectButton; ``` For detailed examples on specific actions like signing messages, sending transactions, or switching networks, please refer to the [Hooks](./hooks#useprovider) and [Examples](#examples) sections. +### 5. Configure Storage + +For data to persist across sessions, you need to provide a storage solution. The `createAppKit` function accepts a `storage` option that must conform to the `Storage` interface. + +The `Storage` interface, which can be imported from `@reown/appkit-react-native`, is defined as follows: + +```typescript +export interface Storage { + /** + * Returns all keys in storage. + */ + getKeys(): Promise; + + /** + * Returns all key-value entries in storage. + */ + getEntries(): Promise<[string, T][]>; + + /** + * Get an item from storage for a given key. + * @param key The key to retrieve. + */ + getItem(key: string): Promise; + + /** + * Set an item in storage for a given key. + * @param key The key to set. + * @param value The value to set. + */ + setItem(key: string, value: T): Promise; + + /** + * Remove an item from storage for a given key. + * @param key The key to remove. + */ + removeItem(key: string): Promise; +} +``` + +**Example with AsyncStorage** + +You can implement this interface using a library like `@react-native-async-storage/async-storage`. Create a new file, for example `src/StorageUtil.ts`, with the following content: + +```typescript +// src/StorageUtil.ts +import AsyncStorage from '@react-native-async-storage/async-storage'; +import { safeJsonParse, safeJsonStringify } from '@walletconnect/safe-json'; +import type { Storage } from '@reown/appkit-react-native'; + +export const storage: Storage = { + getKeys: async () => { + return AsyncStorage.getAllKeys() as Promise; + }, + getEntries: async (): Promise<[string, T][]> => { + function parseEntry(entry: [string, string | null]): [string, any] { + return [entry[0], safeJsonParse(entry[1] ?? '')]; + } + + const keys = await AsyncStorage.getAllKeys(); + const entries = await AsyncStorage.multiGet(keys); + + return entries.map(parseEntry); + }, + setItem: async (key: string, value: any) => { + return await AsyncStorage.setItem(key, safeJsonStringify(value)); + }, + getItem: async (key: string): Promise => { + const item = await AsyncStorage.getItem(key); + if (typeof item === 'undefined' || item === null) { + return undefined; + } + + return safeJsonParse(item) as T; + }, + removeItem: async (key: string) => { + return await AsyncStorage.removeItem(key); + } +}; +``` + +**Update AppKit Configuration** + +Finally, import your custom storage and pass it to `createAppKit` in your `AppKitConfig.ts`. This example builds on the configuration from [Initialize AppKit](#1-initialize-appkit): + +```typescript {7,31} +// src/AppKitConfig.ts (or wherever you prefer to configure it) +import "@walletconnect/react-native-compat"; +import { createAppKit, bitcoin, solana, type AppKitNetwork } from '@reown/appkit-react-native'; +import { EthersAdapter } from '@reown/appkit-ethers-react-native'; +import { SolanaAdapter } from '@reown/appkit-solana-react-native'; +import { BitcoinAdapter } from '@reown/appkit-bitcoin-react-native'; +import { storage } from './StorageUtil'; // 1. Import your custom storage + +// You can use 'viem/chains' or define your own chains using `AppKitNetwork` type. Check Options/networks for more detailed info +import { mainnet, polygon } from 'viem/chains'; + +const projectId = 'YOUR_PROJECT_ID'; // Obtain from Cloud + +const ethersAdapter = new EthersAdapter({ + projectId +}); + +const solanaAdapter = new SolanaAdapter({ + projectId +}); + +const bitcoinAdapter = new BitcoinAdapter({ + projectId +}); + +export const appKit = createAppKit({ + projectId, + networks: [mainnet, polygon, solana, bitcoin], + defaultNetwork: mainnet, + adapters: [ethersAdapter, solanaAdapter, bitcoinAdapter], + storage, + + // Other AppKit options (e.g., metadata for your dApp) + metadata: { + name: 'My Awesome dApp', + description: 'My dApp description', + url: 'https://myapp.com', + icons: ['https://myapp.com/icon.png'], + redirect: { + native: "YOUR_APP_SCHEME://", + universal: "YOUR_APP_UNIVERSAL_LINK.com", + }, + } +}); +``` + ## Enable Wallet Detection From e1f18bedf9bcc74cb16d25516e556ef5f10d1024 Mon Sep 17 00:00:00 2001 From: nacho <25931366+ignaciosantise@users.noreply.github.com> Date: Fri, 11 Jul 2025 14:39:19 -0300 Subject: [PATCH 6/7] chore: improvements --- appkit/react-native/core/email.mdx | 30 ++--- appkit/react-native/core/installation.mdx | 13 +- .../core/migration-multichain.mdx | 39 +++--- appkit/react-native/core/options.mdx | 3 + .../react-native/ethers/about/coinbase.mdx | 17 --- .../ethers/about/implementation.mdx | 124 ----------------- .../ethers/about/installation-expo.mdx | 16 --- .../ethers/about/installation.mdx | 15 --- snippets/appkit/react-native/ethers/email.mdx | 41 ------ snippets/appkit/react-native/ethers/hooks.mdx | 53 -------- .../react-native/ethers5/about/coinbase.mdx | 17 --- .../ethers5/about/implementation.mdx | 125 ------------------ .../ethers5/about/installation-expo.mdx | 16 --- .../ethers5/about/installation.mdx | 15 --- .../appkit/react-native/ethers5/hooks.mdx | 52 -------- .../react-native/expo/additional-expo48.mdx | 51 ------- .../react-native/wagmi/about/coinbase.mdx | 18 --- .../wagmi/about/implementation.mdx | 115 ---------------- .../wagmi/about/installation-expo.mdx | 16 --- .../react-native/wagmi/about/installation.mdx | 15 --- snippets/appkit/react-native/wagmi/email.mdx | 43 ------ snippets/appkit/react-native/wagmi/hooks.mdx | 66 --------- 22 files changed, 42 insertions(+), 858 deletions(-) delete mode 100644 snippets/appkit/react-native/ethers/about/coinbase.mdx delete mode 100644 snippets/appkit/react-native/ethers/about/implementation.mdx delete mode 100644 snippets/appkit/react-native/ethers/about/installation-expo.mdx delete mode 100644 snippets/appkit/react-native/ethers/about/installation.mdx delete mode 100644 snippets/appkit/react-native/ethers/email.mdx delete mode 100644 snippets/appkit/react-native/ethers/hooks.mdx delete mode 100644 snippets/appkit/react-native/ethers5/about/coinbase.mdx delete mode 100644 snippets/appkit/react-native/ethers5/about/implementation.mdx delete mode 100644 snippets/appkit/react-native/ethers5/about/installation-expo.mdx delete mode 100644 snippets/appkit/react-native/ethers5/about/installation.mdx delete mode 100644 snippets/appkit/react-native/ethers5/hooks.mdx delete mode 100644 snippets/appkit/react-native/expo/additional-expo48.mdx delete mode 100644 snippets/appkit/react-native/wagmi/about/coinbase.mdx delete mode 100644 snippets/appkit/react-native/wagmi/about/implementation.mdx delete mode 100644 snippets/appkit/react-native/wagmi/about/installation-expo.mdx delete mode 100644 snippets/appkit/react-native/wagmi/about/installation.mdx delete mode 100644 snippets/appkit/react-native/wagmi/email.mdx delete mode 100644 snippets/appkit/react-native/wagmi/hooks.mdx diff --git a/appkit/react-native/core/email.mdx b/appkit/react-native/core/email.mdx index 962bfe38a..a2f18f50d 100644 --- a/appkit/react-native/core/email.mdx +++ b/appkit/react-native/core/email.mdx @@ -2,8 +2,9 @@ title: Email & Socials --- -import WagmiImplementation from "/snippets/appkit/react-native/wagmi/email.mdx"; -import EthersImplementation from "/snippets/appkit/react-native/ethers/email.mdx"; + + Feature not available yet + AppKit enables passwordless Web3 onboarding and authentication, allowing your users interact with your application by creating a non-custodial wallet with just their emails or social network. @@ -15,27 +16,12 @@ Due to Safariโ€™s strict third-party cookie policies, the SDK is not preserving ## Integration - +### Update your Cloud settings +1. Go to your [Cloud](https://cloud.reown.com) project +2. Open Dashboard and scroll down to Mobile Application IDs menu +3. Add your iOS Bundle ID and/or your Android Package Name +* Changes might take some minutes to impact - - ### Update your Cloud settings - 1. Go to your [Cloud](https://cloud.reown.com) project - 2. Open Dashboard and scroll down to Mobile Application IDs menu - 3. Add your iOS Bundle ID and/or your Android Package Name - * Changes might take some minutes to impact - - - - - - ### Update your Cloud settings 1. Go to your [Cloud](https://cloud.reown.com) - project 2. Open Dashboard and scroll down to Mobile Application IDs menu 3. - Add your iOS Bundle ID and/or your Android Package Name * Changes might take - some minutes to impact - - - - ## Options diff --git a/appkit/react-native/core/installation.mdx b/appkit/react-native/core/installation.mdx index a9ea3a035..806aa0506 100644 --- a/appkit/react-native/core/installation.mdx +++ b/appkit/react-native/core/installation.mdx @@ -3,6 +3,7 @@ title: Installation --- import CloudBanner from "/snippets/cloud-banner.mdx"; +import ExpoBabel from "/snippets/appkit/react-native/expo/babel-config-expo53.mdx" AppKit for React Native enables seamless integration with multiple blockchain ecosystems, including EVM chains (like Ethereum, Polygon, etc.), Solana, and Bitcoin. It provides a unified API to manage wallet connections, interact with different chains, and build rich multi-chain applications. @@ -25,6 +26,8 @@ Installation is a two-step process: npx expo install @reown/appkit-react-native@alpha @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal @react-native-community/netinfo @walletconnect/react-native-compat expo-application ``` + + @@ -606,7 +609,7 @@ To enable Phantom Wallet, you'll need to import the `PhantomConnector` from `@re Here's how to update your `AppKitConfig.ts` file, using the example from the [Implementation](#1-initialize-appkit) section as a base: -```typescript {5,30-32} +```typescript {5,30-40} // src/AppKitConfig.ts (or wherever you prefer to configure it) import "@walletconnect/react-native-compat"; import { createAppKit, bitcoin, solana, type AppKitNetwork } from '@reown/appkit-react-native'; @@ -639,6 +642,14 @@ export const appKit = createAppKit({ extraConnectors: [ new PhantomConnector({ cluster: 'mainnet-beta' }) // Or 'devnet', 'testnet' ], + customWallets: [ + { + id: 'phantom-wallet', + name: 'Phantom', + image_url: 'https://avatars.githubusercontent.com/u/124594793?s=200&v=4', + mobile_link: 'phantom://', + } + ] // Other AppKit options (e.g., metadata for your dApp) }); ``` diff --git a/appkit/react-native/core/migration-multichain.mdx b/appkit/react-native/core/migration-multichain.mdx index 9ebeed778..b7c9a41cc 100644 --- a/appkit/react-native/core/migration-multichain.mdx +++ b/appkit/react-native/core/migration-multichain.mdx @@ -98,31 +98,30 @@ This step is critical for avoiding runtime errors related to missing polyfills. The way you initialize AppKit has changed significantly to support the new adapter-based architecture. -### Old Method (Example from docs.reown.com using Wagmi) +### Old Implementation -Previously, for an EVM setup with Wagmi, you might have done something like this (based on the `docs.reown.com` structure): +Previously, for an EVM setup with Wagmi, you might have done something like this ```typescript -// Old approach (example) -// import { createAppKit, defaultWagmiConfig } from "@reown/appkit-wagmi-react-native"; // Path might vary -// import { mainnet, polygon } from "@wagmi/core/chains"; // Path might vary - -// const projectId = "YOUR_PROJECT_ID"; -// const metadata = { /* ... */ }; -// const chains = [mainnet, polygon]; - -// const wagmiConfig = defaultWagmiConfig({ chains, projectId, metadata }); - -// const appKitInstance = createAppKit({ // createAppKit might have been named differently or part of the adapter pkg -// wagmiConfig, -// projectId, -// metadata, -// chains, // This 'chains' prop might have been for AppKit's own chain display logic -// // ... other options -// }); +// Old implementation +import { createAppKit, defaultWagmiConfig } from "@reown/appkit-wagmi-react-native"; +import { mainnet, polygon } from "@wagmi/chains"; + +const projectId = "YOUR_PROJECT_ID"; +const metadata = { /* ... */ }; +const chains = [mainnet, polygon]; + +const wagmiConfig = defaultWagmiConfig({ chains, projectId, metadata }); + +const appKitInstance = createAppKit({ + wagmiConfig, + projectId, + metadata, + // ... other options +}); ``` -### New Multichain Method +### New Multichain Implementation With the new version, you initialize adapters first and then pass them to `createAppKit` from the core `@reown/appkit-react-native` package. diff --git a/appkit/react-native/core/options.mdx b/appkit/react-native/core/options.mdx index 02fd23459..64476b381 100644 --- a/appkit/react-native/core/options.mdx +++ b/appkit/react-native/core/options.mdx @@ -328,6 +328,9 @@ import * as Clipboard from 'expo-clipboard'; // or from '@react-native-clipboard ``` ## Feature Flags + + Features not available yet + ### `features` * **Type:** `Object` (Optional) diff --git a/snippets/appkit/react-native/ethers/about/coinbase.mdx b/snippets/appkit/react-native/ethers/about/coinbase.mdx deleted file mode 100644 index 9ad93012f..000000000 --- a/snippets/appkit/react-native/ethers/about/coinbase.mdx +++ /dev/null @@ -1,17 +0,0 @@ -8. Initialize `CoinbaseProvider` and add it in the default config - -```tsx -import { CoinbaseProvider } from '@reown/appkit-coinbase-ethers-react-native' - -const coinbaseProvider = new CoinbaseProvider({ - redirect: 'https://your-app-universal-link.com' || 'YOUR_APP_SCHEME://' - rpcUrl: mainnet.rpcUrl -}) - -const config = defaultConfig({ - metadata, - coinbase: coinbaseProvider -}) -``` - -* Prefer universal links over custom schemes to avoid an app verification warning on Coinbase Wallet diff --git a/snippets/appkit/react-native/ethers/about/implementation.mdx b/snippets/appkit/react-native/ethers/about/implementation.mdx deleted file mode 100644 index 5c59ca6d6..000000000 --- a/snippets/appkit/react-native/ethers/about/implementation.mdx +++ /dev/null @@ -1,124 +0,0 @@ -Start by importing `createAppKit` and create your configs as shown below. -Finally, pass your configuration to `createAppKit`. - - - -Make sure you import `@walletconnect/react-native-compat` before using our package to avoid any issues. - - - - -`createAppKit` must be called before rendering the `` component or any other AppKit UI components. Make sure to call `createAppKit` at the module level, outside of your React components. - - -```tsx -import "@walletconnect/react-native-compat"; - -import { - createAppKit, - defaultConfig, - AppKit, -} from "@reown/appkit-ethers-react-native"; - -// 1. Get projectId from https://cloud.reown.com -const projectId = "YOUR_PROJECT_ID"; - -// 2. Create config -const metadata = { - name: "AppKit RN", - description: "AppKit RN Example", - url: "https://reown.com/appkit", - icons: ["https://avatars.githubusercontent.com/u/179229932"], - redirect: { - native: "YOUR_APP_SCHEME://", - }, -}; - -const config = defaultConfig({ metadata }); - -// 3. Define your chains -const mainnet = { - chainId: 1, - name: "Ethereum", - currency: "ETH", - explorerUrl: "https://etherscan.io", - rpcUrl: "https://cloudflare-eth.com", -}; - -const polygon = { - chainId: 137, - name: "Polygon", - currency: "MATIC", - explorerUrl: "https://polygonscan.com", - rpcUrl: "https://polygon-rpc.com", -}; - -const chains = [mainnet, polygon]; - -// 4. Create modal -createAppKit({ - projectId, - chains, - config, - enableAnalytics: true, // Optional - defaults to your Cloud configuration -}); - -export default function App() { - return ( - <> - // Rest of your app... - - - ); -} -``` - -#### Trigger the modal - -To open AppKit modal you can use our **default** button component or build your own logic using our hooks. - - - -You can use our components to open the modal - -```tsx -import { AppKitButton } from "@reown/appkit-ethers-react-native"; - -export default function ConnectView() { - return ( - <> - ...rest of your view - - - ); -} -``` - -Learn more about the AppKit components [here](../../core/components) - - - - -You can trigger the modal by calling the `open` function from `useAppKit` hook. - -```tsx -import { Pressable, Text } from "react-native"; -import { useAppKit } from "@reown/appkit-ethers-react-native"; - -export default function ConnectView() { - const { open } = useAppKit(); - - return ( - <> - open()}> - Open Connect Modal - - - ); -} -``` - -Learn more about the AppKit hooks [here](../../core/hooks) - - - diff --git a/snippets/appkit/react-native/ethers/about/installation-expo.mdx b/snippets/appkit/react-native/ethers/about/installation-expo.mdx deleted file mode 100644 index dd1cd113f..000000000 --- a/snippets/appkit/react-native/ethers/about/installation-expo.mdx +++ /dev/null @@ -1,16 +0,0 @@ -import AdditionalExpo from "/snippets/appkit/react-native/expo/additional-expo48.mdx"; -import BabelConfigExpo53 from "/snippets/appkit/react-native/expo/babel-config-expo53.mdx"; - -``` -npx expo install @reown/appkit-ethers-react-native ethers -``` - -Additionally add these extra packages to help with async storage, polyfills, and SVG's. - -``` -npx expo install @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal@14.0.0-rc.1 @react-native-community/netinfo @walletconnect/react-native-compat expo-application -``` - - - - diff --git a/snippets/appkit/react-native/ethers/about/installation.mdx b/snippets/appkit/react-native/ethers/about/installation.mdx deleted file mode 100644 index 1bb2860a0..000000000 --- a/snippets/appkit/react-native/ethers/about/installation.mdx +++ /dev/null @@ -1,15 +0,0 @@ -``` -yarn add @reown/appkit-ethers-react-native ethers -``` - -Additionally add these extra packages to help with async storage, polyfills, and SVG's. - -``` -yarn add @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal@14.0.0-rc.1 @react-native-community/netinfo @walletconnect/react-native-compat -``` - -On iOS, use CocoaPods to add the native modules to your project: - -``` -npx pod-install -``` diff --git a/snippets/appkit/react-native/ethers/email.mdx b/snippets/appkit/react-native/ethers/email.mdx deleted file mode 100644 index 674ad0f02..000000000 --- a/snippets/appkit/react-native/ethers/email.mdx +++ /dev/null @@ -1,41 +0,0 @@ -### Install packages - -``` -yarn add react-native-webview @reown/appkit-auth-ethers-react-native -``` - -On iOS, use CocoaPods to add the native modules to your project: - -``` -npx pod-install -``` - -### Add the auth connector in `defaultConfig` - -```ts {1-4, 8-9} -// Add the following code lines -import { AuthProvider } from "@reown/appkit-auth-ethers-react-native"; - -const authProvider = new AuthProvider({ projectId, metadata }); - -const config = defaultConfig({ - metadata, - // Add the following code line - extraConnectors: [authProvider], -}); -``` - -### Enable features in `createAppKit` - -```ts {5-9} -createAppKit({ - projectId, - chains, - config, - features: { - email: true, // default to true - socials: ["x", "discord", "apple"], // default value - emailShowWallets: true, // default to true - }, -}); -``` diff --git a/snippets/appkit/react-native/ethers/hooks.mdx b/snippets/appkit/react-native/ethers/hooks.mdx deleted file mode 100644 index 977055981..000000000 --- a/snippets/appkit/react-native/ethers/hooks.mdx +++ /dev/null @@ -1,53 +0,0 @@ -#### useAppKitAccount - -Hook that returns the client's information. - -```tsx -import { useAppKitAccount } from "@reown/appkit-ethers-react-native"; - -function Components() { - const { address, chainId, isConnected } = useAppKitAccount(); - - //... -} -``` - -#### useAppKitProvider - -Hook that returns the `walletProvider` and the `WalletProviderType`. - -```tsx -import { BrowserProvider } from "ethers"; -import { useAppKitProvider } from "@reown/appkit-ethers-react-native"; - -function Components() { - const { walletProvider } = useAppKitProvider(); - - async function onSignMessage() { - const ethersProvider = new BrowserProvider(walletProvider); - const signer = await ethersProvider.getSigner(); - const message = "hello appkit rn + ethers"; - const signature = await signer.signMessage(message); - console.log(signature.toString()); - } - - return ; -} -``` - -#### useAppKitError - -```ts -import { useAppKitError } from "@reown/appkit-ethers-react-native"; - -function Components() { - const { error } = useAppKitError(); - - //... -} -``` - - diff --git a/snippets/appkit/react-native/ethers5/about/coinbase.mdx b/snippets/appkit/react-native/ethers5/about/coinbase.mdx deleted file mode 100644 index a74c0d9b2..000000000 --- a/snippets/appkit/react-native/ethers5/about/coinbase.mdx +++ /dev/null @@ -1,17 +0,0 @@ -8. Initialize `CoinbaseProvider` and add it in the default config - -```tsx -import { CoinbaseProvider } from '@reown/appkit-coinbase-ethers-react-native' - -const coinbaseProvider = new CoinbaseProvider({ - redirect: 'https://your-app-universal-link.com' || 'YOUR_APP_SCHEME://' - rpcUrl: mainnet.rpcUrl -}) - -const config = defaultConfig({ - metadata, - coinbase: coinbaseProvider -}) -``` - -* Prefer universal links over custom schemes to avoid an app verification warning on Coinbase Wallet \ No newline at end of file diff --git a/snippets/appkit/react-native/ethers5/about/implementation.mdx b/snippets/appkit/react-native/ethers5/about/implementation.mdx deleted file mode 100644 index 4058e0cbe..000000000 --- a/snippets/appkit/react-native/ethers5/about/implementation.mdx +++ /dev/null @@ -1,125 +0,0 @@ -Start by importing `createAppKit` and create your configs as shown below. -Finally, pass your configuration to `createAppKit`. - - - -Make sure you import `@walletconnect/react-native-compat` and `@ethersproject/shims` before using our package to avoid any issues. - - - - -`createAppKit` must be called before rendering the `` component or any other AppKit UI components. Make sure to call `createAppKit` at the module level, outside of your React components. - - -```tsx -import "@walletconnect/react-native-compat"; -import "@ethersproject/shims"; - -import { - createAppKit, - defaultConfig, - AppKit, -} from "@reown/appkit-ethers5-react-native"; - -// 1. Get projectId from https://cloud.reown.com -const projectId = "YOUR_PROJECT_ID"; - -// 2. Create config -const metadata = { - name: "AppKit RN", - description: "AppKit RN Example", - url: "https://reown.com/appkit", - icons: ["https://avatars.githubusercontent.com/u/179229932"], - redirect: { - native: "YOUR_APP_SCHEME://", - }, -}; - -const config = defaultConfig({ metadata }); - -// 3. Define your chains -const mainnet = { - chainId: 1, - name: "Ethereum", - currency: "ETH", - explorerUrl: "https://etherscan.io", - rpcUrl: "https://cloudflare-eth.com", -}; - -const polygon = { - chainId: 137, - name: "Polygon", - currency: "MATIC", - explorerUrl: "https://polygonscan.com", - rpcUrl: "https://polygon-rpc.com", -}; - -const chains = [mainnet, polygon]; - -// 4. Create modal -createAppKit({ - projectId, - chains, - config, - enableAnalytics: true, // Optional - defaults to your Cloud configuration -}); - -export default function App() { - return ( - <> - // Rest of your app... - - - ); -} -``` - -#### Trigger the modal - -To open AppKit modal you can use our **default** button component or build your own logic using our hooks. - - - -You can use our components to open the modal - -```tsx -import { AppKitButton } from "@reown/appkit-ethers5-react-native"; - -export default function ConnectView() { - return ( - <> - ...rest of your view - - - ); -} -``` - -Learn more about the AppKit components [here](../../core/components) - - - - -You can trigger the modal by calling the `open` function from `useAppKit` hook. - -```tsx -import { Pressable, Text } from "react-native"; -import { useAppKit } from "@reown/appkit-ethers5-react-native"; - -export default function ConnectView() { - const { open } = useAppKit(); - - return ( - <> - open()}> - Open Connect Modal - - - ); -} -``` - -Learn more about the AppKit hooks [here](../../core/hooks) - - - diff --git a/snippets/appkit/react-native/ethers5/about/installation-expo.mdx b/snippets/appkit/react-native/ethers5/about/installation-expo.mdx deleted file mode 100644 index aff5874b4..000000000 --- a/snippets/appkit/react-native/ethers5/about/installation-expo.mdx +++ /dev/null @@ -1,16 +0,0 @@ -import AdditionalExpo from "/snippets/appkit/react-native/expo/additional-expo48.mdx"; -import BabelConfigExpo53 from "/snippets/appkit/react-native/expo/babel-config-expo53.mdx"; - -``` -npx expo install @reown/appkit-ethers5-react-native ethers@5.7.2 -``` - -Additionally add these extra packages to help with async storage, polyfills, and SVG's. - -``` -npx expo install @ethersproject/shims@5.7.0 @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal@14.0.0-rc.1 @react-native-community/netinfo @walletconnect/react-native-compat expo-application -``` - - - - diff --git a/snippets/appkit/react-native/ethers5/about/installation.mdx b/snippets/appkit/react-native/ethers5/about/installation.mdx deleted file mode 100644 index d80579745..000000000 --- a/snippets/appkit/react-native/ethers5/about/installation.mdx +++ /dev/null @@ -1,15 +0,0 @@ -``` -yarn add @reown/appkit-ethers5-react-native ethers@5.7.2 -``` - -Additionally add these extra packages to help with async storage, polyfills, and SVG's. - -``` -yarn add @ethersproject/shims@5.7.0 @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal@14.0.0-rc.1 @react-native-community/netinfo @walletconnect/react-native-compat -``` - -On iOS, use CocoaPods to add the native modules to your project: - -``` -npx pod-install -``` diff --git a/snippets/appkit/react-native/ethers5/hooks.mdx b/snippets/appkit/react-native/ethers5/hooks.mdx deleted file mode 100644 index 8adcc5132..000000000 --- a/snippets/appkit/react-native/ethers5/hooks.mdx +++ /dev/null @@ -1,52 +0,0 @@ -#### useAppKitAccount - -Hook that returns the client's information. - -```tsx -import { useAppKitAccount } from "@reown/appkit-ethers5-react-native"; - -function Components() { - const { address, chainId, isConnected } = useAppKitAccount(); - - //... -} -``` - -#### useAppKitProvider - -Hook that returns the `walletProvider` and the `WalletProviderType`. - -```tsx -import { ethers } from "ethers"; -import { useAppKitProvider } from "@reown/appkit-ethers5-react-native"; - -function Components() { - const { walletProvider } = useAppKitProvider(); - - async function onSignMessage() { - const provider = new ethers.providers.Web3Provider(walletProvider); - const signer = provider.getSigner(); - const signature = await signer?.signMessage("Hello AppKit Ethers"); - console.log(signature); - } - - return ; -} -``` - -#### useAppKitError - -```ts -import { useAppKitError } from "@reown/appkit-ethers5-react-native"; - -function Components() { - const { error } = useAppKitError(); - - //... -} -``` - - diff --git a/snippets/appkit/react-native/expo/additional-expo48.mdx b/snippets/appkit/react-native/expo/additional-expo48.mdx deleted file mode 100644 index e6d42723b..000000000 --- a/snippets/appkit/react-native/expo/additional-expo48.mdx +++ /dev/null @@ -1,51 +0,0 @@ -
-Additional setup for Expo SDK 48 only -
- -If you are using Expo SDK 48, you also need to polyfill `crypto` with expo-crypto library. - -1. Add `expo-crypto` - -``` -npx expo install expo-crypto -``` - -2. Create a file named `crypto-polyfill.js` - -```js -// src/crypto-polyfill.js - -// Apply only with Expo SDK 48 -import { getRandomValues as expoCryptoGetRandomValues } from "expo-crypto"; - -class Crypto { - getRandomValues = expoCryptoGetRandomValues; -} - -// eslint-disable-next-line no-undef -const webCrypto = typeof crypto !== "undefined" ? crypto : new Crypto(); - -(() => { - if (typeof crypto === "undefined") { - Object.defineProperty(window, "crypto", { - configurable: true, - enumerable: true, - get: () => webCrypto, - }); - } -})(); -``` - -3. Import `crypto-polyfill.js` in your App root file - -```js -// src/App.js - -import './crypto-polyfill.js' -import '@walletconnect/react-native-compat'; -... -import { createAppKit } from '@reown/appkit-...' -``` - -
-
diff --git a/snippets/appkit/react-native/wagmi/about/coinbase.mdx b/snippets/appkit/react-native/wagmi/about/coinbase.mdx deleted file mode 100644 index cd413b6bd..000000000 --- a/snippets/appkit/react-native/wagmi/about/coinbase.mdx +++ /dev/null @@ -1,18 +0,0 @@ -8. Initialize `coinbaseConnector` and add it in `extraConnectors` - -```tsx -import { coinbaseConnector } from '@reown/appkit-coinbase-wagmi-react-native' - -const coinbase = coinbaseConnector({ - redirect: 'https://your-app-universal-link.com' || 'YOUR_APP_SCHEME://' -}) - -const wagmiConfig = defaultWagmiConfig({ - chains, - projectId, - metadata, - extraConnectors: [coinbase] -}) -``` - -* Prefer universal links over custom schemes to avoid an app verification warning on Coinbase Wallet diff --git a/snippets/appkit/react-native/wagmi/about/implementation.mdx b/snippets/appkit/react-native/wagmi/about/implementation.mdx deleted file mode 100644 index 0e37e5293..000000000 --- a/snippets/appkit/react-native/wagmi/about/implementation.mdx +++ /dev/null @@ -1,115 +0,0 @@ -Start by importing `createAppKit`, and wagmi packages, then create your configs as shown below. -Finally, pass your configuration to `createAppKit`. - - - -Make sure you import `@walletconnect/react-native-compat` before `wagmi` to avoid any issues. - - - - -`createAppKit` must be called before rendering the `` component or any other AppKit UI components. Make sure to call `createAppKit` at the module level, outside of your React components. - - -```tsx -import "@walletconnect/react-native-compat"; -import { WagmiProvider } from "wagmi"; -import { mainnet, polygon, arbitrum } from "@wagmi/core/chains"; -import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import { - createAppKit, - defaultWagmiConfig, - AppKit, -} from "@reown/appkit-wagmi-react-native"; - -// 0. Setup queryClient -const queryClient = new QueryClient(); - -// 1. Get projectId at https://cloud.reown.com -const projectId = "YOUR_PROJECT_ID"; - -// 2. Create config -const metadata = { - name: "AppKit RN", - description: "AppKit RN Example", - url: "https://reown.com/appkit", - icons: ["https://avatars.githubusercontent.com/u/179229932"], - redirect: { - native: "YOUR_APP_SCHEME://", - universal: "YOUR_APP_UNIVERSAL_LINK.com", - }, -}; - -const chains = [mainnet, polygon, arbitrum] as const; - -const wagmiConfig = defaultWagmiConfig({ chains, projectId, metadata }); - -// 3. Create modal -createAppKit({ - projectId, - wagmiConfig, - defaultChain: mainnet, // Optional - enableAnalytics: true, // Optional - defaults to your Cloud configuration -}); - -export default function App() { - return ( - - - // Rest of your app... - - - - ); -} -``` - -#### Trigger the modal - -To open AppKit modal you can use our **default** button component or build your own logic using our hooks. - - - -You can use our components to open the modal - -```tsx -import { AppKitButton } from "@reown/appkit-wagmi-react-native"; - -export default function ConnectView() { - return ( - <> - ...rest of your view - - - ); -} -``` - -Learn more about the AppKit components [here](../../core/components) - - - - -You can trigger the modal by calling the `open` function from `useAppKit` hook. - -```tsx -import { Pressable, Text } from "react-native"; -import { useAppKit } from "@reown/appkit-wagmi-react-native"; - -export default function ConnectView() { - const { open } = useAppKit(); - - return ( - <> - open()}> - Open Connect Modal - - - ); -} -``` - -Learn more about the AppKit hooks [here](../../core/hooks) - - - diff --git a/snippets/appkit/react-native/wagmi/about/installation-expo.mdx b/snippets/appkit/react-native/wagmi/about/installation-expo.mdx deleted file mode 100644 index 4acd18355..000000000 --- a/snippets/appkit/react-native/wagmi/about/installation-expo.mdx +++ /dev/null @@ -1,16 +0,0 @@ -import AdditionalExpo from "/snippets/appkit/react-native/expo/additional-expo48.mdx"; -import BabelConfigExpo53 from "/snippets/appkit/react-native/expo/babel-config-expo53.mdx"; - -``` -npx expo install @reown/appkit-wagmi-react-native wagmi viem @tanstack/react-query -``` - -Additionally add these extra packages to help with async storage, polyfills, and SVG's. - -``` -npx expo install @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal@14.0.0-rc.1 @react-native-community/netinfo @walletconnect/react-native-compat expo-application -``` - - - - diff --git a/snippets/appkit/react-native/wagmi/about/installation.mdx b/snippets/appkit/react-native/wagmi/about/installation.mdx deleted file mode 100644 index 78ac088e7..000000000 --- a/snippets/appkit/react-native/wagmi/about/installation.mdx +++ /dev/null @@ -1,15 +0,0 @@ -``` -yarn add @reown/appkit-wagmi-react-native wagmi viem @tanstack/react-query -``` - -Additionally add these extra packages to help with async storage, polyfills, and SVG's. - -``` -yarn add @react-native-async-storage/async-storage react-native-get-random-values react-native-svg react-native-modal@14.0.0-rc.1 @react-native-community/netinfo @walletconnect/react-native-compat -``` - -On iOS, use CocoaPods to add the native modules to your project: - -``` -npx pod-install -``` diff --git a/snippets/appkit/react-native/wagmi/email.mdx b/snippets/appkit/react-native/wagmi/email.mdx deleted file mode 100644 index 43474f70f..000000000 --- a/snippets/appkit/react-native/wagmi/email.mdx +++ /dev/null @@ -1,43 +0,0 @@ -### Install packages - -``` -yarn add @reown/appkit-auth-wagmi-react-native react-native-webview -``` - -On iOS, use CocoaPods to add the native modules to your project: - -``` -npx pod-install -``` - -### Add the auth connector in `defaultWagmiConfig` - -```ts {1-4, 10-11} -// Add the following code lines -import { authConnector } from "@reown/appkit-auth-wagmi-react-native"; - -const auth = authConnector({ projectId, metadata }); - -const wagmiConfig = defaultWagmiConfig({ - chains, - projectId, - metadata, - // Add the following code line - extraConnectors: [auth], -}); -``` - -### Enable features in `createAppKit` - -```ts {4-9} -createAppKit({ - projectId, - wagmiConfig, - // Add the following code line - features: { - email: true, // default to true - socials: ["x", "discord", "apple"], // default value - emailShowWallets: true, // default to true - }, -}); -``` diff --git a/snippets/appkit/react-native/wagmi/hooks.mdx b/snippets/appkit/react-native/wagmi/hooks.mdx deleted file mode 100644 index 33343009e..000000000 --- a/snippets/appkit/react-native/wagmi/hooks.mdx +++ /dev/null @@ -1,66 +0,0 @@ -### useAppKitAccount - -Hook that returns the client's information. - -```tsx -import { useAppKitAccount } from "@reown/appkit/react"; - -function Components() { - const { address, caipAddress, isConnected } = useAppKitAccount(); - - //... -} -``` - -#### useSignMessage - -Hook for signing messages with connected account. - -```tsx -import { View, Text, Pressable } from "react-native"; -import { useSignMessage } from "wagmi"; - -function App() { - const { data, isError, isPending, isSuccess, signMessage } = useSignMessage(); - - return ( - - signMessage({ message: "hello world" })} - > - Sign message - - {isSuccess && Signature: {data}} - {isError && Error signing message} - - ); -} -``` - -#### useReadContract - -Hook for calling a read method on a Contract. - -```tsx -import { View, Text } from "react-native"; -import { useReadContract } from "./abi"; - -function App() { - const { data, isError, isPending, isSuccess } = useReadContract({ - abi, - address: "0x6b175474e89094c44da98b954eedeac495271d0f", - functionName: "totalSupply", - }); - - return ( - - {isPending && Loading} - {isSuccess && Response: {data?.toString()}} - {isError && Error reading contract} - - ); -} -``` - - From ef4eb25b6c60fa1ed7bf87bc13a2d9279df351a2 Mon Sep 17 00:00:00 2001 From: TomTom Date: Fri, 11 Jul 2025 15:33:37 -0300 Subject: [PATCH 7/7] Update appkit/react-native/core/components.mdx --- appkit/react-native/core/components.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appkit/react-native/core/components.mdx b/appkit/react-native/core/components.mdx index 75474df95..cf4d9f0cb 100644 --- a/appkit/react-native/core/components.mdx +++ b/appkit/react-native/core/components.mdx @@ -2,7 +2,7 @@ title: Components --- -AppKit comes with a set of pre-built UI components to help you quickly integrate wallet connection and display functionalities into your React Native application. You can import them directly from `@reown/appkit-react-native`. +AppKit comes with a set of pre-built UI components to help you quickly integrate wallet connection and display functionalities into your React Native application. You can import them directly from `@reown/appkit-react-native`. ### ``