Skip to content

Commit eafdf54

Browse files
authored
Updated docs (#1569)
Co-authored-by: mfbz <mfbz@users.noreply.github.com>
1 parent c002134 commit eafdf54

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

docs/build/tools/clients/fcl-js/packages-docs/fcl/createFlowClient.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@ description: "createFlowClient function documentation."
77

88
# createFlowClient
99

10-
Creates a Flow client instance with authentication, transaction, and query capabilities.
10+
Creates a Flow client instance with scoped configuration.
11+
12+
This function decouples FCL functions from the global state and constructs a new SDK client
13+
instance bound to a custom context. This allows for better modularity and supports multiple
14+
FCL instances in the same application, each with their own isolated configuration and state.
15+
16+
Benefits of scoped configuration:
17+
- **Isolation**: Each client has its own configuration, storage, and state
18+
- **Multi-tenancy**: Connect to different Flow networks simultaneously
19+
- **Type Safety**: Configuration is validated at compile time via TypeScript
20+
- **Testing**: Easy to create isolated client instances for testing
1121

1222
## Import
1323

@@ -27,6 +37,34 @@ import { createFlowClient } from "@onflow/fcl"
2737
createFlowClient(params)
2838
```
2939

40+
## Usage
41+
42+
```typescript
43+
// Multiple isolated clients for different networks
44+
import { createFlowClient } from "@onflow/fcl"
45+
46+
const mainnetClient = createFlowClient({
47+
accessNodeUrl: "https://rest-mainnet.onflow.org",
48+
flowNetwork: "mainnet",
49+
appDetailTitle: "My App (Mainnet)",
50+
})
51+
52+
const testnetClient = createFlowClient({
53+
accessNodeUrl: "https://rest-testnet.onflow.org",
54+
flowNetwork: "testnet",
55+
appDetailTitle: "My App (Testnet)",
56+
})
57+
58+
// Query both networks simultaneously
59+
const [mainnetBlock, testnetBlock] = await Promise.all([
60+
mainnetClient.query({
61+
cadence: `access(all) fun main(): UInt64 { return getCurrentBlock().height }`,
62+
}),
63+
testnetClient.query({
64+
cadence: `access(all) fun main(): UInt64 { return getCurrentBlock().height }`,
65+
}),
66+
])
67+
```
3068

3169
## Parameters
3270

@@ -122,6 +160,6 @@ export interface FlowClientConfig {
122160
```
123161
124162
125-
A Flow client object with many methods for interacting with the Flow blockchain
163+
A Flow client object with methods for interacting with the Flow blockchain
126164
127165
---

docs/build/tools/clients/fcl-js/packages-docs/fcl/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ This section contains documentation for all of the functions and namespaces in t
240240
- [cadence](./cadence.md) - Creates a template function
241241
- [cdc](./cdc.md) - Creates a template function
242242
- [config](./config.md) - Sets the config
243-
- [createFlowClient](./createFlowClient.md) - Creates a Flow client instance with authentication, transaction, and query...
243+
- [createFlowClient](./createFlowClient.md) - Creates a Flow client instance with scoped configuration. This function...
244244
- [createSignableVoucher](./createSignableVoucher.md) - Creates a signable voucher object from an interaction for signing purposes. A...
245245
- [currentUser](./currentUser.md) - The main current user service for managing user authentication and authorization...
246246
- [decode](./decode.md) - Decodes the response from &#x27;fcl.send()&#x27; into the appropriate JSON representation...

0 commit comments

Comments
 (0)