> ## Documentation Index
> Fetch the complete documentation index at: https://second.tech/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get started with React Native

> Add Ark payments to your React Native app. Create a wallet, generate addresses, and check your balance in minutes.

<Prompt description="Use this prompt to get started quickly." icon="microchip" iconType="solid" actions={["copy", "cursor"]}>
  # Bark React Native SDK

  Build Ark wallet apps with `@secondts/bark-react-native`. Ark is a Bitcoin layer 2 protocol for instant, low-fee, self-custodial payments.

  ## Prerequisites

  * React Native 0.74+ with New Architecture enabled
  * iOS 13+ / Android API 24+
  * Expo: development build required (Expo Go is not supported)

  ## Install (Expo)

  ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  npx expo install @secondts/bark-react-native
  ```

  Add the plugin to `app.json`: `{ "expo": { "plugins": ["@secondts/bark-react-native"] } }`, then run `npx expo prebuild`.

  ## Install (Bare React Native)

  ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  npm install @secondts/bark-react-native
  cd ios && pod install && cd ..
  ```

  If you use pnpm v10+, run `pnpm approve-builds` and select `@secondts/bark-react-native`.

  ## Create a wallet

  Note: If you are on expo, using `expo-file-system` instead of `react-native-fs`.

  ```tsx theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import {
    generateMnemonic,
    Config,
    Network,
    Wallet,
  } from "@secondts/bark-react-native";
  import RNFS from "react-native-fs";

  const mnemonic = generateMnemonic();
  const config = Config.create({
    serverAddress: "https://ark.signet.2nd.dev",
    esploraAddress: "https://esplora.signet.2nd.dev",
    network: Network.Signet,
    bitcoindAddress: undefined,
    bitcoindCookiefile: undefined,
    bitcoindUser: undefined,
    bitcoindPass: undefined,
    vtxoRefreshExpiryThreshold: undefined,
    vtxoExitMargin: undefined,
    htlcRecvClaimDelta: undefined,
    fallbackFeeRate: undefined,
    roundTxRequiredConfirmations: undefined,
    daemonFastSyncIntervalSecs: undefined,
    daemonSlowSyncIntervalSecs: undefined,
  });
  const dataDir = `${RNFS.DocumentDirectoryPath}/bark_wallet`;
  await RNFS.mkdir(dataDir);
  const wallet = await Wallet.create(mnemonic, config, dataDir, false);
  ```

  ## Get address and check balance

  ```tsx theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const address = await wallet.newAddress();
  await wallet.sync();
  const balance = await wallet.balance();
  console.log(balance.spendableSats, "sats");
  ```

  ## Signet test environment

  * Ark server: [https://ark.signet.2nd.dev](https://ark.signet.2nd.dev)
  * Block explorer (Esplora): [https://esplora.signet.2nd.dev](https://esplora.signet.2nd.dev)
  * Faucet for test bitcoin: [https://signet.2nd.dev/](https://signet.2nd.dev/)
  * Network enum: `Network.Signet`

  ## Rules

  * New Architecture must be enabled (`newArchEnabled=true`).
  * Use `Wallet.create()` (static method), not `WalletCreate()` or `new Wallet()`.
  * `Config.create()` uses named parameters. All optional fields should be explicitly set to `undefined`.
  * Use `Network.Signet` (enum value), not a string or standalone constant.
  * Wallet operations are async. Always use `await`.
  * `react-native-fs` (RNFS) is required for file system access.
  * Expo Go is not supported. Use a development build.
  * Use `Network.Signet` for testing. Never use mainnet without user confirmation.
  * Never hardcode mnemonics in production code.
  * Correct terminology: Ark (not ARC), VTXO (not vtxo), on-chain (not onchain), off-chain (not offchain).
  * "Bark" (capitalized) in prose, "bark" (lowercase) for the package name and CLI commands.
</Prompt>

## Prerequisites

* React Native 0.74+ with the [New Architecture](https://reactnative.dev/docs/new-architecture-intro) enabled
* iOS 13+ / Android API 24+
* For Expo: a [development build](https://docs.expo.dev/develop/development-builds/introduction/) (Expo Go is not supported)

## Getting started

<Steps>
  <Step title="Install the SDK">
    <Tabs>
      <Tab title="Expo">
        ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
        npx expo install @secondts/bark-react-native
        ```

        Add the plugin to your `app.json`:

        ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
        {
          "expo": {
            "plugins": ["@secondts/bark-react-native"]
          }
        }
        ```

        Then prebuild:

        ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
        npx expo prebuild
        ```
      </Tab>

      <Tab title="Bare React Native">
        ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
        npm install @secondts/bark-react-native
        ```

        For iOS, install the CocoaPods dependencies:

        ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
        cd ios && pod install && cd ..
        ```
      </Tab>
    </Tabs>

    <Note>
      If you use pnpm v10+, run `pnpm approve-builds` and select `@secondts/bark-react-native` to allow the postinstall script.
    </Note>
  </Step>

  <Step title="Create a wallet">
    Generate a BIP39 mnemonic, configure the wallet for signet, and initialize it.

    <Tabs>
      <Tab title="Expo">
        ```tsx theme={"theme":{"light":"github-light","dark":"github-dark"}}
        import {
          generateMnemonic,
          Config,
          Network,
          Wallet,
        } from '@secondts/bark-react-native';
        import { Directory, Paths } from "expo-file-system";

        const BARK_DIR = ".bark";

        // Generate a new mnemonic
        const mnemonic = generateMnemonic();
        console.log('Mnemonic:', mnemonic);

        // Configure for signet
        const config = Config.create({
          serverAddress: 'https://ark.signet.2nd.dev',
          esploraAddress: 'https://esplora.signet.2nd.dev',
          network: Network.Signet,
          bitcoindAddress: undefined,
          bitcoindCookiefile: undefined,
          bitcoindUser: undefined,
          bitcoindPass: undefined,
          vtxoRefreshExpiryThreshold: undefined,
          vtxoExitMargin: undefined,
          htlcRecvClaimDelta: undefined,
          fallbackFeeRate: undefined,
          roundTxRequiredConfirmations: undefined,
          daemonFastSyncIntervalSecs: undefined,
          daemonSlowSyncIntervalSecs: undefined,
        });

        // Create the wallet
        const dataDir = new Directory(Paths.document, BARK_DIR);
        if (!dataDir.exists) dataDir.create();
        const dataPath = dataDir.uri.replace("file://", "").replace(/\/+$/, "");
        const wallet = await Wallet.create(mnemonic, config, dataPath, false);
        ```
      </Tab>

      <Tab title="Bare React Native">
        ```tsx theme={"theme":{"light":"github-light","dark":"github-dark"}}
        import {
          generateMnemonic,
          Config,
          Network,
          Wallet,
        } from '@secondts/bark-react-native';
        import RNFS from 'react-native-fs';

        // Generate a new mnemonic
        const mnemonic = generateMnemonic();
        console.log('Mnemonic:', mnemonic);

        // Configure for signet
        const config = Config.create({
          serverAddress: 'https://ark.signet.2nd.dev',
          esploraAddress: 'https://esplora.signet.2nd.dev',
          network: Network.Signet,
          bitcoindAddress: undefined,
          bitcoindCookiefile: undefined,
          bitcoindUser: undefined,
          bitcoindPass: undefined,
          vtxoRefreshExpiryThreshold: undefined,
          vtxoExitMargin: undefined,
          htlcRecvClaimDelta: undefined,
          fallbackFeeRate: undefined,
          roundTxRequiredConfirmations: undefined,
          daemonFastSyncIntervalSecs: undefined,
          daemonSlowSyncIntervalSecs: undefined,
        });

        // Create the wallet
        const dataDir = `${RNFS.DocumentDirectoryPath}/bark_wallet`;
        await RNFS.mkdir(dataDir);
        const wallet = await Wallet.create(mnemonic, config, dataDir, false);
        ```
      </Tab>
    </Tabs>

    <Note>
      Back up the mnemonic securely. It is the only way to recover your wallet.
    </Note>
  </Step>

  <Step title="Get a receiving address">
    Generate an Ark address to receive funds.

    ```tsx theme={"theme":{"light":"github-light","dark":"github-dark"}}
    const address = await wallet.newAddress();
    console.log('Ark address:', address);
    ```

    Send some signet sats to this address using [the faucet](https://signet.2nd.dev/).
  </Step>

  <Step title="Check your balance">
    Sync the wallet with the Ark server and read your balance.

    ```tsx theme={"theme":{"light":"github-light","dark":"github-dark"}}
    await wallet.sync();

    const balance = await wallet.balance();
    console.log('Spendable:', balance.spendableSats, 'sats');
    ```
  </Step>
</Steps>

## Next steps

<CardGroup cols={2}>
  <Card title="Source and examples" icon="https://mintcdn.com/second-0659a37d/IZIYL7kfKRS394NE/images/gitlab-icon-outline.svg?fit=max&auto=format&n=IZIYL7kfKRS394NE&q=85&s=31497d40e3e7174b42f13799a0b33eb5" href="https://gitlab.com/ark-bitcoin/bark-ffi-bindings/-/tree/master/react-native" width="192" height="192" data-path="images/gitlab-icon-outline.svg">
    Full React Native source and example projects on GitLab.
  </Card>

  <Card title="How Ark works" icon="graduation-cap" href="/learn/intro">
    Learn about the protocol powering your wallet.
  </Card>
</CardGroup>
