zap in context.md

This commit is contained in:
Chad Curtis 2025-07-13 06:51:24 +00:00
parent 14eccbcb6f
commit 11ac73776c

View File

@ -651,6 +651,27 @@ export function Post(/* ...props */) {
} }
``` ```
### Lightning Zaps (NIP-57)
Implement zaps with a payment method fallback chain: **NWC → WebLN → Manual**. Always validate recipient lightning addresses (`lud16`/`lud06`) before creating zap requests.
```tsx
// Use unified wallet detection
const { webln, activeNWC, preferredMethod } = useWallet();
const { zap } = useZaps(target, webln, activeNWC, onSuccess);
// Validate recipient can receive zaps
if (!author.metadata?.lud16 && !author.metadata?.lud06) {
return null; // Hide zap button
}
```
**Critical patterns:**
- Detect WebLN only when needed (dialog open)
- Show payment method indicator to users
- Handle errors gracefully with specific messaging
- Use `useZaps` hook for payment logic
## App Configuration ## App Configuration
The project includes an `AppProvider` that manages global application state including theme and relay configuration. The default configuration includes: The project includes an `AppProvider` that manages global application state including theme and relay configuration. The default configuration includes: