@thru/react-sdk 0.0.7 → 0.0.10

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.
Files changed (2) hide show
  1. package/README.md +61 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # @thru/react-sdk
2
+
3
+ React bindings for the Thru browser wallet. The package wraps `@thru/browser-sdk`, exposes context providers, and ships hooks for accessing connection state, accounts, and the typed Thru RPC client inside React applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @thru/react-sdk
9
+ ```
10
+
11
+ > **Note:** React 18+ is required (declared as a peer dependency).
12
+
13
+ ## Basic Usage
14
+
15
+ ```tsx
16
+ import { ThruProvider, useWallet, useAccounts } from '@thru/react-sdk';
17
+
18
+ function WalletPanel() {
19
+ const { connect, disconnect, isConnected, isConnecting } = useWallet();
20
+ const { accounts, selectedAccount } = useAccounts();
21
+
22
+ if (!isConnected) {
23
+ return (
24
+ <button onClick={() => connect()} disabled={isConnecting}>
25
+ {isConnecting ? 'Connecting…' : 'Connect Thru Wallet'}
26
+ </button>
27
+ );
28
+ }
29
+
30
+ return (
31
+ <section>
32
+ <p>Selected account: {selectedAccount?.address}</p>
33
+ <ul>
34
+ {accounts.map((account) => (
35
+ <li key={account.address}>{account.address}</li>
36
+ ))}
37
+ </ul>
38
+ <button onClick={() => disconnect()}>Disconnect</button>
39
+ </section>
40
+ );
41
+ }
42
+
43
+ export function App() {
44
+ return (
45
+ <ThruProvider
46
+ config={{
47
+ iframeUrl: 'https://thru-wallet.up.railway.app/embedded',
48
+ rpcUrl: 'https://grpc-web.alphanet.thruput.org',
49
+ }}
50
+ >
51
+ <WalletPanel />
52
+ </ThruProvider>
53
+ );
54
+ }
55
+ ```
56
+
57
+ The provider creates a shared `BrowserSDK` instance and exposes:
58
+
59
+ - `useWallet()` — connect/disconnect helpers plus access to the embedded provider API
60
+ - `useAccounts()` — subscribe to accounts and the current selection
61
+ - `useThru()` — raw context (including the underlying `BrowserSDK` and the `Thru` RPC client for data queries)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thru/react-sdk",
3
- "version": "0.0.7",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -11,9 +11,9 @@
11
11
  }
12
12
  },
13
13
  "dependencies": {
14
- "@thru/browser-sdk": "0.0.7",
15
- "@thru/chain-interfaces": "0.0.7",
16
- "@thru/thru-sdk": "0.0.7"
14
+ "@thru/browser-sdk": "0.0.10",
15
+ "@thru/chain-interfaces": "0.0.10",
16
+ "@thru/thru-sdk": "0.0.10"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": "^18.0.0 || ^19.0.0",