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

# Installation & Setup

> Get started with the Spice Flow SDK in your React application

This reference targets stable `@spicenet-io/spiceflow-ui@4.19.0`. See the
[migration guide](https://spiceflow-docs.spicenet.io/sdk/migration.md) when upgrading an existing integration.

## Installation

Install the stable version described by this reference:

```bash theme={null}
bun add @spicenet-io/spiceflow-ui@4.19.0
```

The UI package depends on core 0.8.2. If your application imports core directly, declare that same
version explicitly to keep helpers and types aligned.

## Peer Dependencies

The SDK requires the following peer dependencies. Install based on your wallet provider:

### Required Dependencies

These are always required:

```bash theme={null}
bun add react@18 react-dom@18 viem wagmi @tanstack/react-query
```

| Package | Version | Description |
| - | - | - |
| `react` | `^18.0.0` | React library |
| `react-dom` | `^18.0.0` | React DOM |
| `viem` | `>=2.21.0` | Ethereum interface library |
| `wagmi` | `>=2.12.0` | React hooks for Ethereum |
| `@tanstack/react-query` | `>=5.0.0` | Data fetching library |

> [!NOTE]
>
> Keep the app on React 18 and resolve peers within the declared ranges. Do not bypass peer conflicts
> as a default setup step. Reuse an existing compatible wallet/provider stack.

### Wallet Provider

The SDK uses Privy for wallet connections:

```bash theme={null}
bun add "@privy-io/react-auth@>=2.24.0 <4.0.0"
```

| Package | Version | Provider |
| - | - | - |
| `@privy-io/react-auth` | `>=2.24.0 <4.0.0` | Privy |

***

## Complete Installation

```bash theme={null}
bun add @spicenet-io/spiceflow-ui@4.19.0 @spicenet-io/spiceflow-core@0.8.2 "@privy-io/react-auth@>=2.24.0 <4.0.0" react@18 react-dom@18 viem wagmi @tanstack/react-query
```

***

## Basic Setup

### 1. Mount the Provider Stack

`SpiceFlowProvider` reads wallet state from Privy, wagmi, and react-query — it does not mount them.
Your app provides all four, in this order. The SDK injects its stylesheet automatically in the browser;
an existing explicit `styles.css` import remains supported:

```tsx theme={null}
<WagmiProvider config={wagmiConfig}>
  <QueryClientProvider client={queryClient}>
    <PrivyProvider appId={PRIVY_APP_ID} config={privyConfig}>
      <SpiceFlowProvider provider="privy" network="mainnet" nativeChainId={8453}>
        {/* Your app components */}
      </SpiceFlowProvider>
    </PrivyProvider>
  </QueryClientProvider>
</WagmiProvider>
```

See [Quick Start Step 2](https://spiceflow-docs.spicenet.io/quickstart.md#step-2-setup-providers) for the full wagmi and Privy configs.
Already running Privy? Reuse your existing `PrivyProvider` — add the chains you enable to its
`supportedChains` and your wagmi config.

### 2. Add Wallet Connection

Use the `ProviderLogin` component to let users connect their wallet:

```tsx theme={null}
import { ProviderLogin } from "@spicenet-io/spiceflow-ui";

function Header() {
  return (
    <div>
      <ProviderLogin />
    </div>
  );
}
```

### 3. Add an Action and Account Menu

Use `SpiceSupply` for protocol calls, or `useSpiceSupply` for your own UI. See the complete
[Quick Start example](https://spiceflow-docs.spicenet.io/quickstart.md#step-3-add-a-protocol-action).

For account funding and Spice-balance withdrawals, the combined component needs no modal wiring:

```tsx theme={null}
import { SpiceAccount } from "@spicenet-io/spiceflow-ui";

export function AccountMenu() {
  return <SpiceAccount />;
}
```

The SDK supplies default fee/funding batches, token metadata, venues and styles. Protocol addresses,
ABIs, recipient policy and any required application updates remain yours to define.

***

## Next.js Considerations

If you're using Next.js with Server-Side Rendering (SSR), wrap components that use Spice Flow in a client component:

```tsx theme={null}
"use client"; // Add this directive at the top

import { SpiceFlowProvider } from "@spicenet-io/spiceflow-ui";
```

Or check for the window object:

```tsx theme={null}
if (typeof window === 'undefined') {
  return <div>Loading...</div>;
}
```

***

## Environment Variables

Store your provider credentials in environment variables:

```env theme={null}
NEXT_PUBLIC_PRIVY_APP_ID=your_privy_app_id
```

Then use them in your code:

```tsx theme={null}
<PrivyProvider appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID}>
```

The app ID belongs on your own `PrivyProvider`. `SpiceFlowProvider` has a `privyAppId` prop, but it has no effect.

***

## Next Steps

> [card] [Components](https://spiceflow-docs.spicenet.io/sdk/components.md)
>
> Learn about all available components and their props

> [card] [Hooks](https://spiceflow-docs.spicenet.io/sdk/hooks.md)
>
> Use React hooks to build custom UIs

> [card] [Configuration](https://spiceflow-docs.spicenet.io/sdk/configuration.md)
>
> Configure wallet providers, chains, and more

> [card] [Quick Start Guide](https://spiceflow-docs.spicenet.io/quickstart.md)
>
> Build your first Spice Flow app step-by-step


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.