@crossmint/client-sdk-react-native-ui 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -30
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,67 +1,146 @@
|
|
|
1
1
|
# Crossmint React Native SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Create chain-agnostic wallets for your React Native apps in minutes**
|
|
4
|
+
> Supports Solana, 20+ EVM chains (Polygon, Base, etc.), with secure mobile authentication.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## 🚀 Quick Start
|
|
6
7
|
|
|
7
8
|
```bash
|
|
8
9
|
pnpm add @crossmint/client-sdk-react-native-ui expo-secure-store expo-web-browser
|
|
9
10
|
```
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
### 1. Setup Providers
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
### Using the Default Secure Storage
|
|
16
|
-
|
|
17
|
-
The `CrossmintAuthProvider` uses SecureStorage by default:
|
|
14
|
+
**Option A: With Crossmint Authentication (Recommended)**
|
|
18
15
|
|
|
19
16
|
```tsx
|
|
20
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
CrossmintProvider,
|
|
19
|
+
CrossmintAuthProvider,
|
|
20
|
+
CrossmintWalletProvider
|
|
21
|
+
} from "@crossmint/client-sdk-react-native-ui";
|
|
21
22
|
|
|
22
23
|
export default function App() {
|
|
23
24
|
return (
|
|
24
|
-
<CrossmintProvider
|
|
25
|
-
apiKey="YOUR_API_KEY"
|
|
26
|
-
>
|
|
25
|
+
<CrossmintProvider apiKey={process.env.EXPO_PUBLIC_CROSSMINT_API_KEY}>
|
|
27
26
|
<CrossmintAuthProvider>
|
|
28
|
-
|
|
27
|
+
<CrossmintWalletProvider
|
|
28
|
+
createOnLogin={{
|
|
29
|
+
chain: "solana",
|
|
30
|
+
signer: { type: "email" }
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<MainApp />
|
|
34
|
+
</CrossmintWalletProvider>
|
|
29
35
|
</CrossmintAuthProvider>
|
|
30
36
|
</CrossmintProvider>
|
|
31
37
|
);
|
|
32
38
|
}
|
|
33
39
|
```
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
**Option B: 🔧 Bring Your Own Authentication**
|
|
42
|
+
|
|
43
|
+
Already have authentication? Skip Crossmint Auth and use wallets with your existing system:
|
|
44
|
+
|
|
45
|
+
📖 **[Complete Custom Auth Guide](https://docs.crossmint.com/wallets/advanced/bring-your-own-auth#react-native)** - Full setup with server-side examples and implementation details.
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import {
|
|
49
|
+
CrossmintProvider,
|
|
50
|
+
CrossmintWalletProvider
|
|
51
|
+
} from "@crossmint/client-sdk-react-native-ui";
|
|
52
|
+
|
|
53
|
+
export default function App() {
|
|
54
|
+
return (
|
|
55
|
+
<CrossmintProvider apiKey={process.env.EXPO_PUBLIC_CROSSMINT_API_KEY}>
|
|
56
|
+
{/* No CrossmintAuthProvider needed! */}
|
|
57
|
+
<CrossmintWalletProvider>
|
|
58
|
+
<MainApp />
|
|
59
|
+
</CrossmintWalletProvider>
|
|
60
|
+
</CrossmintProvider>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2. Use Authentication & Wallets
|
|
36
66
|
|
|
37
|
-
|
|
67
|
+
The React Native SDK uses [Expo's SecureStore](https://docs.expo.dev/versions/latest/sdk/securestore/) for secure, encrypted storage of authentication tokens. This provides a platform-native secure storage solution that encrypts sensitive data on the device.
|
|
38
68
|
|
|
39
69
|
```tsx
|
|
40
|
-
import {
|
|
70
|
+
import { View, Button, Text } from "react-native";
|
|
71
|
+
import { useCrossmintAuth, useWallet } from "@crossmint/client-sdk-react-native-ui";
|
|
41
72
|
|
|
42
|
-
function
|
|
43
|
-
const {
|
|
73
|
+
export default function MainApp() {
|
|
74
|
+
const { loginWithOAuth, logout, user } = useCrossmintAuth();
|
|
75
|
+
const { wallet, status } = useWallet();
|
|
44
76
|
|
|
45
|
-
if (
|
|
77
|
+
if (!user) {
|
|
46
78
|
return (
|
|
47
|
-
<View>
|
|
48
|
-
<Button
|
|
49
|
-
title="
|
|
50
|
-
onPress={() =>
|
|
79
|
+
<View style={{ padding: 20 }}>
|
|
80
|
+
<Button
|
|
81
|
+
title="Login with Google"
|
|
82
|
+
onPress={() => loginWithOAuth("google")}
|
|
51
83
|
/>
|
|
52
84
|
</View>
|
|
53
85
|
);
|
|
54
86
|
}
|
|
55
87
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
88
|
+
if (status === "loaded") {
|
|
89
|
+
return (
|
|
90
|
+
<View style={{ padding: 20 }}>
|
|
91
|
+
<Text>Welcome {user.email}!</Text>
|
|
92
|
+
<Text>Wallet: {wallet?.address}</Text>
|
|
93
|
+
<Button
|
|
94
|
+
title="Send 1 USDC"
|
|
95
|
+
onPress={() => wallet?.send(recipient, "usdc", "1.0")}
|
|
96
|
+
/>
|
|
97
|
+
<Button title="Logout" onPress={logout} />
|
|
98
|
+
</View>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return <Text>Loading wallet...</Text>;
|
|
62
103
|
}
|
|
63
104
|
```
|
|
64
105
|
|
|
106
|
+
## 🔐 Authentication
|
|
107
|
+
|
|
108
|
+
### OAuth Login Methods
|
|
109
|
+
```tsx
|
|
110
|
+
const { loginWithOAuth } = useCrossmintAuth();
|
|
111
|
+
|
|
112
|
+
// Available OAuth providers
|
|
113
|
+
<Button title="Google" onPress={() => loginWithOAuth("google")} />
|
|
114
|
+
<Button title="Twitter" onPress={() => loginWithOAuth("twitter")} />
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## 💳 Wallets
|
|
118
|
+
|
|
119
|
+
### Multi-Chain Support
|
|
120
|
+
- **Solana**: Native SOL, SPL tokens
|
|
121
|
+
- **EVM Chains**: Ethereum, Polygon, Base, Arbitrum, and 15+ more
|
|
122
|
+
- **Unified API**: Same code works across all chains
|
|
123
|
+
|
|
124
|
+
### Using Wallets
|
|
125
|
+
```tsx
|
|
126
|
+
const { wallet, getOrCreateWallet } = useWallet();
|
|
127
|
+
|
|
128
|
+
// Get wallet info
|
|
129
|
+
const address = wallet?.address;
|
|
130
|
+
const balance = await wallet?.balances();
|
|
131
|
+
|
|
132
|
+
// Send tokens
|
|
133
|
+
const tx = await wallet?.send(recipient, "usdc", "10.5");
|
|
134
|
+
console.log("Transaction:", tx.explorerLink);
|
|
135
|
+
|
|
136
|
+
// For advanced use cases
|
|
137
|
+
const customWallet = await getOrCreateWallet({
|
|
138
|
+
chain: "<your-chain>",
|
|
139
|
+
signer: { type: "<your-signer-type>" }
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
|
|
65
144
|
## Custom Storage Provider
|
|
66
145
|
|
|
67
146
|
If you need to implement a custom storage solution, you can implement the `StorageProvider` interface and pass it to the `CrossmintAuthProvider`:
|
|
@@ -98,4 +177,28 @@ function App() {
|
|
|
98
177
|
}
|
|
99
178
|
```
|
|
100
179
|
|
|
101
|
-
|
|
180
|
+
## 🛠️ Environment Setup
|
|
181
|
+
|
|
182
|
+
1. Get your API key from [Crossmint Console](https://staging.crossmint.com/console/projects/apiKeys)
|
|
183
|
+
|
|
184
|
+
2. Add to your `.env`:
|
|
185
|
+
```bash
|
|
186
|
+
EXPO_PUBLIC_CROSSMINT_API_KEY=your_api_key_here
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
3. Configure deep linking in `app.json`:
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"expo": {
|
|
193
|
+
"scheme": "your-app-scheme"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## 📚 Examples & Documentation
|
|
199
|
+
|
|
200
|
+
- **[Wallets Expo Quickstart](https://github.com/Crossmint/wallets-expo-quickstart)** - Create and interact with Crossmint wallets using Crossmint Auth for React Native.
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
**Questions?** Visit our [documentation](https://docs.crossmint.com/introduction/about-crossmint) or contact our support team.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossmint/client-sdk-react-native-ui",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"repository": "https://github.com/Crossmint/crossmint-sdk",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Paella Labs Inc",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"react-native-webview": "13.12.5",
|
|
27
27
|
"@crossmint/client-sdk-auth": "1.2.16",
|
|
28
28
|
"@crossmint/client-sdk-base": "1.5.7",
|
|
29
|
-
"@crossmint/client-sdk-react-base": "0.5.
|
|
29
|
+
"@crossmint/client-sdk-react-base": "0.5.6",
|
|
30
30
|
"@crossmint/client-sdk-rn-window": "0.2.2",
|
|
31
|
-
"@crossmint/client-signers": "0.0.18",
|
|
32
31
|
"@crossmint/common-sdk-auth": "1.0.38",
|
|
32
|
+
"@crossmint/client-signers": "0.0.18",
|
|
33
33
|
"@crossmint/common-sdk-base": "0.8.1",
|
|
34
|
-
"@crossmint/wallets-sdk": "0.10.
|
|
34
|
+
"@crossmint/wallets-sdk": "0.10.6"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/react": "19.0.12"
|