# @universal-everything/sdk-vue

Vue 3 composables for the universal-relayer API. Mirrors the
`sdk-react` shape; returns Vue `Ref`s so template auto-unwrap Just
Works.

## Install

```bash
pnpm add @universal-everything/sdk-vue @universal-everything/sdk-core
```

## Quick start

```vue
<!-- App.vue -->
<script setup lang="ts">
import { WalletKitClient } from "@universal-everything/sdk-core";
import { provideWalletKit } from "@universal-everything/sdk-vue";

const client = new WalletKitClient({
  baseUrl: import.meta.env.VITE_RELAYER_BASE,
  getAccessToken: async () => localStorage.getItem("token"),
});

provideWalletKit(client);
</script>

<template>
  <Wallets />
</template>
```

```vue
<!-- Wallets.vue -->
<script setup lang="ts">
import { useWallets, useSignMessage } from "@universal-everything/sdk-vue";

const wallets = useWallets();
const signMessage = useSignMessage();
</script>

<template>
  <p v-if="wallets.isLoading.value">Loading…</p>
  <p v-else-if="wallets.error.value">Error: {{ wallets.error.value.code }}</p>
  <div v-else>
    <div v-for="w in wallets.data.value" :key="w.walletId">
      {{ w.address }}
    </div>
    <button
      :disabled="signMessage.isPending.value"
      @click="signMessage.mutate('hello')"
    >
      Sign
    </button>
  </div>
</template>
```

## Composables

### Queries — `{ data, error, isLoading, isSuccess, refetch }` (all refs)

- `useWallets()` — list the user's wallets.
- `useWallet(id | Ref<id | null>)` — one wallet; `Ref` input refetches
  on change, null stays idle.
- `useProfiles()` — list UPs with controllers.
- `useProfile(id | Ref<id | null>)` — one UP.
- `useQuota()` — current quota snapshot.

### Mutations — `{ mutate, data, error, isPending, reset }`

- `useSignMessage()` — `mutate(message, opts?)`
- `useSignTransaction()` — `mutate(tx, opts?)`
- `useSignLsp25()` — `mutate(input, opContext?)`
- `useRelaySponsored()` — `mutate(input, opContext?)`

`mutate` returns a `Promise<TResult>` so you can `await` inline;
`data` / `error` / `isPending` mirror state as `Ref`s for template
bindings.

## Context plumbing

`provideWalletKit(client)` is a thin wrapper around Vue's `provide`,
keyed on an exported `WALLET_KIT_KEY` (`Symbol.for(...)` so even
duplicated bundles resolve the same key). `useWalletKit()` throws a
clear error if no ancestor called `provideWalletKit` — catches missing
root wiring at dev time rather than producing undefined fetches.

If you prefer Vue plugins (`app.use(...)`), wrap `provideWalletKit`
yourself — it's three lines. We don't ship one because the surface
area isn't worth the docs.

## UI components

For plug-and-play UI, see [`@universal-everything/ui`](../ui/) — Lit web
components drop into Vue templates as regular custom elements.
