createFcl
Creates a configured FCL (Flow Client Library) instance for web applications. This function initializes FCL with web-specific defaults and discovery configuration, providing a complete interface for interacting with the Flow blockchain.
The created FCL instance includes all core functionality for:
- User authentication and wallet connections
- Transaction submission and monitoring
- Blockchain queries and event subscriptions
- Configuration management
- Discovery service integration
This function automatically configures the platform as "web" and uses localStorage for session persistence by default, while allowing customization of other parameters.
Import
You can import the entire package and access the function:
_10import * as fcl from "@onflow/fcl"_10_10fcl.createFcl(params)
Or import directly the specific function:
_10import { createFcl } from "@onflow/fcl"_10_10createFcl(params)
Usage
_12// Basic FCL instance creation_12import { createFcl } from "@onflow/fcl"_12_12const fcl = createFcl({_12 accessNodeUrl: "https://rest-testnet.onflow.org",_12 computeLimit: 1000,_12 flowNetwork: "testnet"_12})_12_12// Use the instance for authentication_12const user = await fcl.currentUser.authenticate()_12console.log("Authenticated user:", user.addr)
Parameters
params
- Type:
_10WithOptionalProperties<any, "platform" | "storage">
- Description: Configuration parameters for the FCL instance
Properties:
accessNodeUrl
- URL of the Flow access node (e.g., "https://rest-testnet.onflow.org")computeLimit
- Default compute limit for transactions and queriescustomResolver
- Optional custom resolver for address replacementcustomDecoders
- Optional custom decoders for response parsingcontracts
- Optional contract address mappingsdiscoveryWallet
- Optional discovery wallet endpointdiscoveryWalletMethod
- Optional discovery wallet methoddefaultComputeLimit
- Optional default compute limit overrideflowNetwork
- Optional Flow network identifierserviceOpenIdScopes
- Optional OpenID scopes for serviceswalletconnectProjectId
- Optional WalletConnect project IDwalletconnectDisableNotifications
- Optional flag to disable WalletConnect notificationsstorage
- Optional custom storage provider (defaults to localStorage)discovery
- Optional discovery configuration
Returns
any
A fully configured FCL instance with all core methods and services