<!--
Sitemap:
- [MBGA · Reactive Primitives for Spark](/index)
- [Acknowledgments](/acknowledgments)
- [API Reference](/api/)
- [Connectors](/connectors/)
- [Examples](/examples/)
- [Flashnet](/flashnet/)
- [Getting Started](/getting-started)
- [Installation](/installation)
- [Kit](/kit/)
- [Configuration](/api/configuration)
- [Core Actions](/api/core-actions)
- [React Hooks](/api/hooks)
- [Types & Errors](/api/types)
- [Custom Connectors](/connectors/custom)
- [Sats Connect (Xverse)](/connectors/sats-connect)
- [Spark SDK](/connectors/spark-sdk)
- [Wallet Standard](/connectors/wallet-standard)
- [Flashnet Authentication](/flashnet/authentication)
- [Next.js](/frameworks/nextjs)
- [Vite](/frameworks/vite)
- [AccountModal](/kit/account-modal)
- [ConnectButton](/kit/connect-button)
- [ConnectModal](/kit/connect-modal)
-->

# Examples

Working example apps demonstrating MBGA in different frameworks.

## Vite + React

A minimal React app with wallet connection, balance display, payments, invoice creation, message signing, and fee estimation.

**Source:** [examples/vite-react](https://github.com/refrakts/mbga/tree/main/examples/vite-react)

```bash
# Run locally
git clone https://github.com/refrakts/mbga.git
cd mbga
pnpm install
pnpm dev:vite
```

### Features demonstrated

* Wallet connection / disconnection
* Balance display with auto-refresh
* Send payment (Lightning, on-chain, Spark)
* Create invoice to receive payments
* Wait for incoming payment
* Sign message (BIP-322)
* Estimate transaction fees
* Transaction lookup

***

## Next.js (App Router)

SSR-compatible setup using Next.js App Router with `'use client'` directives and SSR-safe storage.

**Source:** [examples/nextjs](https://github.com/refrakts/mbga/tree/main/examples/nextjs)

```bash
# Run locally
git clone https://github.com/refrakts/mbga.git
cd mbga
pnpm install
pnpm dev:next
```

### Key differences from Vite

* `ssr: true` in config to prevent hydration mismatches
* `createStorage()` with `typeof window` guard
* `'use client'` directive on all component files
* Provider wrapper in a separate client component

***

## Scaffold Your Own

Use `create-mbga` to generate a new project with MBGA pre-configured:

:::code-group

```bash [npm]
npm create mbga@latest
```

```bash [pnpm]
pnpm create mbga
```

```bash [yarn]
yarn create mbga
```

:::
