Skip to main content

MinaProvider

The MinaProvider component initializes and shares a Mina SDK instance with all child components through React context.

Import

Props

MinaProviderProps

MinaConfig

Context Value

MinaContextValue

The provider exposes the following through context:

Basic Setup

Full Configuration

Next.js App Router Setup

For Next.js App Router, create a separate client component for providers:
The 'use client' directive is required. MinaProvider uses React hooks internally and cannot be rendered on the server.

Combining with Other Providers

When using multiple providers (e.g., wagmi, TanStack Query), nest them appropriately:
app/providers.tsx
MinaProvider does not depend on wagmi or TanStack Query. You can use it standalone or alongside these libraries.

Dynamic Configuration

For environment-based configuration:
app/providers.tsx

Error Handling

Handle initialization errors in child components:

Configuration Stability

The provider uses stable configuration comparison. If the config object reference changes but values remain the same, the SDK will not reinitialize:

Best Practices

  1. Place provider high in the tree - Wrap your entire app or the section that needs bridge functionality
  2. Use 'use client' - Required for Next.js App Router
  3. Memoize config - Prevents unnecessary re-renders
  4. Handle initialization states - Check isReady and error in consuming components
  5. Use environment variables - For RPC URLs and environment-specific config

Next Steps

useMina

Access the SDK instance in components

useQuote

Fetch bridge quotes