Skip to content

[react-native] added onramp and swaps docs #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion appkit/react-native/core/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Allows you to toggle (enable or disable) additional features provided by AppKit.

### swaps

Enable or disable the swap feature in your AppKit. [Swaps](/appkit/react/transactions/swaps) feature is enabled by default.
Enable or disable the swap feature in your AppKit. [Swaps](/appkit/react-native/transactions/swaps) feature is enabled by default.

```ts
createAppKit({
Expand All @@ -180,6 +180,19 @@ createAppKit({
});
```

### onramp

Enable or disable the On-Ramp feature in your AppKit. [On-Ramp](/appkit/react-native/transactions/onramp) feature is enabled by default.

```ts
createAppKit({
//...
features: {
onramp: true,
},
});
```

### email

This boolean defines whether you want to enable email login. This feature is enabled by default.
Expand Down
60 changes: 60 additions & 0 deletions appkit/react-native/transactions/onramp.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: On-Ramp
---

Enable users to purchase crypto with fiat directly within your React Native app using AppKit's On-Ramp feature. This integration allows users to securely access over 100 cryptocurrencies and purchase tokens to support in-app activity and transactions across multiple chains.

## Configuration

The On-Ramp feature is enabled by default in AppKit. Here's how to configure it in your app:

```typescript
import { createAppKit } from '@reown/appkit...';

createAppKit({
projectId: 'YOUR_PROJECT_ID',
// ... other config options
features: {
onramp: true, // Optional - true by default
}
});
```

If you want to disable the On-Ramp feature, you can set `onramp: false` in the features configuration.

## Usage

### Opening the On-Ramp View

You can programmatically open the On-Ramp view using the `useAppKit` hook:

```typescript
import { useAppKit } from '@reown/appkit...';

function BuyButton() {
const { open } = useAppKit();

const handleBuyPress = () => {
open({ view: 'OnRamp' });
};

return (
<Button
title="Buy Crypto"
onPress={handleBuyPress}
/>
);
}
```

### User Flow

1. When users tap the "Buy Crypto" button or select it from the account view, they'll be presented with available On-Ramp interface where they can:
- Select the cryptocurrency they want to purchase
- Select the country and fiat currency
- Choose the amount
- Select their preferred payment method

2. After reviewing the purchase details, the user will be redirected to the browser to finish the transaction.

3. Once the purchase is complete, the crypto will be sent directly to their connected wallet address.
66 changes: 66 additions & 0 deletions appkit/react-native/transactions/swaps.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: Swaps
---

Enable users to easily switch between crypto assets without leaving your React Native app. With Swaps, users can easily and securely swap tokens right within your app via AppKit. Set up in minutes with just one line of code.

## Configuration

The Swaps feature is enabled by default in AppKit. Here's how to configure it in your app:

```typescript
import { createAppKit } from '@reown/appkit...';

createAppKit({
projectId: 'YOUR_PROJECT_ID',
// ... other config options
features: {
swaps: true, // Optional - true by default
}
});
```

If you want to disable the Swaps feature, you can set `swaps: false` in the features configuration.

## Usage

### Opening the Swaps View

You can programmatically open the Swaps view using the `useAppKit` hook:

```typescript
import { useAppKit } from '@reown/appkit-...';

function SwapButton() {
const { open } = useAppKit();

const handleSwapPress = () => {
open({ view: 'Swap' });
};

return (
<Button
title="Swap Tokens"
onPress={handleSwapPress}
/>
);
}
```

### User Flow

1. When users tap the "Swap Tokens" button or select it from the account view, they'll be presented with the Swaps interface.

2. In the Swaps interface, users can:
- Select the token they want to swap from
- Select the token they want to swap to
- Enter the amount they want to swap
- Review the transaction details including:
- Price impact
- Network cost
- Slippage tolerance
- Provider fee

3. After reviewing the transaction details, users can confirm the swap.

4. Once confirmed, the transaction will be processed and the tokens will be swapped in their wallet.
7 changes: 7 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,13 @@
]
}
]
},
{
"group": "Transactions",
"pages": [
"appkit/react-native/transactions/swaps",
"appkit/react-native/transactions/onramp"
]
}
]
},
Expand Down