Guide

Vue / Nuxt

Integrate Buff with Solana wallet adapter or Reown.

Install

$npm install buff-protocol-sdk solana-wallets-vueCopy

Composable

useBuff.ts
typescript
1import { ref, watch } from 'vue'
2import { useWallet } from 'solana-wallets-vue'
3import { Buff } from 'buff-protocol-sdk'
4
5export function useBuff(apiKey: string) {
6 const buff = ref<Buff | null>(null)
7 const { signMessage, publicKey } = useWallet()
8
9 watch([signMessage, publicKey], async ([sign, pk]) => {
10 if (!sign || !pk) { buff.value = null; return }
11
12 const b = new Buff({
13 apiKey,
14 plan: 'sprout',
15 investInto: 'BTC',
16 })
17
18 // Authenticate with wallet signature
19 const msg = new TextEncoder().encode('Sign in to Buff')
20 const sig = await sign(msg)
21 b.setWalletAuth(pk.toBase58(), Buffer.from(sig).toString('base64'))
22 buff.value = b
23 }, { immediate: true })
24
25 return { buff }
26}
Note
Both approaches use the same Buff SDK. Authentication is via API key or wallet signature headers — no signMessage callback needed.