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

# Configure Horizon Endpoints with Stellar Libraries

> Set up and configure Stellar Horizon API endpoints for different networks in React Native

Configure Horizon API endpoints for Stellar to connect to different networks, use custom nodes, or optimize performance. Stellar uses [Horizon](https://developers.stellar.org/docs/data/horizon) as its HTTP API layer instead of traditional RPC endpoints.

<Card title="Setup Stellar Libraries First" description="You must complete the Stellar library setup before configuring Horizon endpoints" href="/v3/react-native/guides/web3-operations/stellar/setup-libraries" horizontal />

## Configure Horizon Server

```typescript theme={null}
import { Horizon, Networks } from "@stellar/stellar-sdk";

// Public Horizon endpoints
const mainnetServer = new Horizon.Server("https://horizon.stellar.org");
const testnetServer = new Horizon.Server("https://horizon-testnet.stellar.org");

// Custom Horizon endpoint (e.g., self-hosted or third-party provider)
const customServer = new Horizon.Server("https://your-custom-horizon.example.com", {
  allowHttp: false, // set to true only for local development
});
```

## Switch Networks

When switching between mainnet and testnet, update both the Horizon URL and the network passphrase used for signing:

```typescript theme={null}
import { useParaStellarSigner } from "@getpara/react-native-wallet/stellar";
import { Horizon, Networks } from "@stellar/stellar-sdk";

type StellarNetwork = "mainnet" | "testnet";

const NETWORK_CONFIG = {
  mainnet: {
    horizonUrl: "https://horizon.stellar.org",
    networkPassphrase: Networks.PUBLIC,
  },
  testnet: {
    horizonUrl: "https://horizon-testnet.stellar.org",
    networkPassphrase: Networks.TESTNET,
  },
} as const;

function useStellarNetwork(network: StellarNetwork) {
  const config = NETWORK_CONFIG[network];

  const { stellarSigner, isLoading } = useParaStellarSigner({
    networkPassphrase: config.networkPassphrase,
  });

  const server = new Horizon.Server(config.horizonUrl);

  return { server, stellarSigner, isLoading, networkPassphrase: config.networkPassphrase };
}
```

## Check Server Health

```typescript theme={null}
import { Horizon } from "@stellar/stellar-sdk";

async function checkHorizonHealth() {
  const server = new Horizon.Server("https://horizon.stellar.org");

  // Get ledger info
  const ledger = await server.ledgers().order("desc").limit(1).call();
  const latestLedger = ledger.records[0];
  console.log("Latest ledger:", latestLedger.sequence);
  console.log("Closed at:", latestLedger.closed_at);

  // Get fee stats
  const feeStats = await server.feeStats();
  console.log("Base fee:", feeStats.last_ledger_base_fee);
  console.log("Fee charged (p50):", feeStats.fee_charged.p50);
}
```

## Next Steps

<CardGroup cols={3}>
  <Card title="Query Balances" description="Check XLM and token balances" href="/v3/react-native/guides/web3-operations/stellar/query-balances" icon="wallet" />

  <Card title="Send Tokens" description="Transfer XLM between accounts" href="/v3/react-native/guides/web3-operations/stellar/send-tokens" icon="paper-plane" />

  <Card title="Execute Transactions" description="Build complex Stellar transactions" href="/v3/react-native/guides/web3-operations/stellar/execute-transactions" icon="bolt" />
</CardGroup>
