A minimal Next.js starter template for building Flow blockchain applications using @onflow/react-sdk. This starter includes interactive tutorials and examples to help you get started quickly.
- Next.js with App Router and Turbopack
- Flow React SDK
@onflow/react-sdkpre-configured - FlowProvider wrapper with Testnet configuration
- Interactive tutorials with working examples:
- Wallet connection with official Connect component
- Testnet faucet integration
- Balance checking with
useFlowQuery - Token transfers with
useFlowMutate
- Network indicator showing current Flow network (Testnet/Mainnet/Emulator)
- Responsive design optimized for mobile, tablet, and desktop
npm install
# or
yarn install
# or
pnpm installnpm run dev
# or
yarn dev
# or
pnpm devOpen http://localhost:3000 with your browser.
npm run buildsrc/
├── app/
│ ├── layout.tsx # Root layout with FlowProvider
│ ├── page.tsx # Main landing page (Server Component)
│ └── globals.css # Global styles
└── components/
├── flow-provider-wrapper.tsx # FlowProvider configuration
├── flow-header.tsx # Header with Connect component & network indicator
├── flow-content.tsx # Main content component (Client Component)
└── tutorial/
├── wallet-connect.tsx # Step 1: Wallet connection tutorial
├── faucet-funding.tsx # Step 2: Testnet faucet integration
├── flow-balance.tsx # Step 3: Balance query example (useFlowQuery)
└── send-flow.tsx # Step 4: Token transfer example (useFlowMutate)
The FlowProvider is configured in src/components/flow-provider-wrapper.tsx with Flow Testnet by default.
To switch networks, update the config:
Mainnet:
accessNodeUrl: "https://rest-mainnet.onflow.org",
discoveryWallet: "https://fcl-discovery.onflow.org/mainnet/authn",
flowNetwork: "mainnet",Emulator:
accessNodeUrl: "http://localhost:8888",
discoveryWallet: "http://localhost:8701/fcl/authn",
discoveryAuthnEndpoint: "http://localhost:8701/fcl/authn",
flowNetwork: "emulator",The Flow Emulator allows you to run a local Flow blockchain for development and testing. The Connect button works seamlessly with the emulator's dev wallet.
Install the Flow CLI (full installation guide):
# macOS (Homebrew - recommended)
brew install flow-cli
# macOS/Linux (pre-built binary)
sudo sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
# Windows (PowerShell)
iex "& { $(irm 'https://raw.githubusercontent.com/onflow/flow-cli/master/install.ps1') }"Verify installation:
flow versionThis project has been initialized with flow init, which created the necessary Cadence development environment:
cadence/
├── contracts/
│ └── Counter.cdc # Example smart contract
├── scripts/
│ └── GetCounter.cdc # Script to read contract state
├── transactions/
│ └── IncrementCounter.cdc # Transaction to modify state
└── tests/
└── Counter_test.cdc # Contract tests
flow.json # Flow configuration file
emulator-account.pkey # Emulator account private keyIMPORTANT: You must start BOTH the Flow Emulator AND the Dev Wallet before trying to connect your wallet in the application.
-
Start the Flow Emulator (Terminal 1):
flow emulator start
This starts the Flow Emulator on
http://localhost:8888. Keep this terminal window open. -
Start the Dev Wallet (Terminal 2):
Open a new terminal and run:
flow dev-wallet
This starts the Dev Wallet on
http://localhost:8701. Keep this terminal window open as well. -
Configure FlowProvider for Emulator
The
src/components/flow-provider-wrapper.tsxis already configured for the emulator with theflowJsonprop:import flowJSON from "../../flow.json"; export function FlowProviderWrapper({ children }: FlowProviderWrapperProps) { return ( <FlowProvider config={{ // Emulator configuration accessNodeUrl: "http://localhost:8888", discoveryWallet: "http://localhost:8701/fcl/authn", flowNetwork: "emulator", // App metadata appDetailTitle: "Flow React SDK Starter", appDetailUrl: typeof window !== "undefined" ? window.location.origin : "", appDetailIcon: "https://avatars.githubusercontent.com/u/62387156?v=4", appDetailDescription: "A Next.js starter template for Flow blockchain applications", // Optional configuration computeLimit: 1000, }} flowJson={flowJSON} > {children} </FlowProvider> ); }
The
flowJsonprop automatically loads contract addresses and account configuration fromflow.json, making it easier to work with deployed contracts on the emulator. -
Start the NextJS Development Server (Terminal 3):
Open another terminal and run:
npm run dev
-
Connect with Dev Wallet:
Click the "Connect Wallet" button - it will open the Flow Dev Wallet UI at
http://localhost:8701. The dev wallet comes with pre-funded test accounts ready to use.
The starter includes interactive tutorial components that demonstrate core Flow SDK features:
import { Connect } from "@onflow/react-sdk";
// Official Connect component with wallet discovery
<Connect />Get Flow Wallet to get started.
import { useFlowCurrentUser, useFlowQuery } from "@onflow/react-sdk";
const { user } = useFlowCurrentUser();
const { data: balance, isLoading, error, refetch } = useFlowQuery({
cadence: FLOW_BALANCE_SCRIPT,
args: (arg, t) => [arg(user?.addr || "", t.Address)],
});The useFlowQuery hook executes Cadence scripts to read blockchain data.
import { useFlowMutate } from "@onflow/react-sdk";
const { mutate, isPending, isSuccess, error } = useFlowMutate();
const handleSend = () => {
const formattedAmount = parseFloat(amount).toFixed(8);
mutate({
cadence: TRANSFER_FLOW_TRANSACTION,
args: (arg, t) => [arg(formattedAmount, t.UFix64), arg(recipient, t.Address)],
});
};The useFlowMutate hook executes Cadence transactions that modify blockchain state.
- Flow Wallet - Official Flow wallet
- Flow Testnet Faucet - Get free testnet tokens
- Flow React SDK Documentation - Complete SDK reference
- Flow Developer Portal - Developer resources
- Cadence Documentation - Smart contract language
- FCL GitHub - Flow Client Library
- FlowScan - Testnet block explorer