From 7ca0d1a4d02d24a668426257df26e625e6468dcf Mon Sep 17 00:00:00 2001 From: mfbz Date: Mon, 10 Nov 2025 23:48:07 +0100 Subject: [PATCH] Updated docs --- .../packages-docs/fcl/createFlowClient.md | 42 ++++++++++++++++++- .../clients/fcl-js/packages-docs/fcl/index.md | 2 +- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/docs/build/tools/clients/fcl-js/packages-docs/fcl/createFlowClient.md b/docs/build/tools/clients/fcl-js/packages-docs/fcl/createFlowClient.md index e865d9c3fd..4ca231e3a3 100644 --- a/docs/build/tools/clients/fcl-js/packages-docs/fcl/createFlowClient.md +++ b/docs/build/tools/clients/fcl-js/packages-docs/fcl/createFlowClient.md @@ -7,7 +7,17 @@ description: "createFlowClient function documentation." # createFlowClient -Creates a Flow client instance with authentication, transaction, and query capabilities. +Creates a Flow client instance with scoped configuration. + +This function decouples FCL functions from the global state and constructs a new SDK client +instance bound to a custom context. This allows for better modularity and supports multiple +FCL instances in the same application, each with their own isolated configuration and state. + +Benefits of scoped configuration: +- **Isolation**: Each client has its own configuration, storage, and state +- **Multi-tenancy**: Connect to different Flow networks simultaneously +- **Type Safety**: Configuration is validated at compile time via TypeScript +- **Testing**: Easy to create isolated client instances for testing ## Import @@ -27,6 +37,34 @@ import { createFlowClient } from "@onflow/fcl" createFlowClient(params) ``` +## Usage + +```typescript +// Multiple isolated clients for different networks +import { createFlowClient } from "@onflow/fcl" + +const mainnetClient = createFlowClient({ + accessNodeUrl: "https://rest-mainnet.onflow.org", + flowNetwork: "mainnet", + appDetailTitle: "My App (Mainnet)", +}) + +const testnetClient = createFlowClient({ + accessNodeUrl: "https://rest-testnet.onflow.org", + flowNetwork: "testnet", + appDetailTitle: "My App (Testnet)", +}) + +// Query both networks simultaneously +const [mainnetBlock, testnetBlock] = await Promise.all([ + mainnetClient.query({ + cadence: `access(all) fun main(): UInt64 { return getCurrentBlock().height }`, + }), + testnetClient.query({ + cadence: `access(all) fun main(): UInt64 { return getCurrentBlock().height }`, + }), +]) +``` ## Parameters @@ -122,6 +160,6 @@ export interface FlowClientConfig { ``` -A Flow client object with many methods for interacting with the Flow blockchain +A Flow client object with methods for interacting with the Flow blockchain --- \ No newline at end of file diff --git a/docs/build/tools/clients/fcl-js/packages-docs/fcl/index.md b/docs/build/tools/clients/fcl-js/packages-docs/fcl/index.md index 82df7dd42c..e8abf586a4 100644 --- a/docs/build/tools/clients/fcl-js/packages-docs/fcl/index.md +++ b/docs/build/tools/clients/fcl-js/packages-docs/fcl/index.md @@ -240,7 +240,7 @@ This section contains documentation for all of the functions and namespaces in t - [cadence](./cadence.md) - Creates a template function - [cdc](./cdc.md) - Creates a template function - [config](./config.md) - Sets the config -- [createFlowClient](./createFlowClient.md) - Creates a Flow client instance with authentication, transaction, and query... +- [createFlowClient](./createFlowClient.md) - Creates a Flow client instance with scoped configuration. This function... - [createSignableVoucher](./createSignableVoucher.md) - Creates a signable voucher object from an interaction for signing purposes. A... - [currentUser](./currentUser.md) - The main current user service for managing user authentication and authorization... - [decode](./decode.md) - Decodes the response from 'fcl.send()' into the appropriate JSON representation...