Frameworks
Vue
Vue 3
terminalbash
bun add @iconical/presencekitSingle presence composable
Presence.vuevue
<script setup lang="ts">
import { usePresence } from "@iconical/presencekit/vue";
const { data, loading, error, refresh } = usePresence({
userId: "123456789012345678",
transport: "auto",
});
</script>
<template>
<p v-if="loading">Connecting…</p>
<button v-else-if="error" @click="refresh">Retry</button>
<div v-else-if="data">
<strong>{{ data.profile.displayName }}</strong>
<p>{{ data.presence?.status ?? "Pending" }}</p>
</div>
</template>The composable returns Vue refs (data, loading, error) and a refresh() function. It subscribes on mount and cleans up on unmount. Call from or a setup function, not arbitrary module scope.
Multiple people
multi-user.tstypescript
import { usePresences, useConnectionDiagnostics } from "@iconical/presencekit/vue";
const group = usePresences({
userIds: ["123456789012345678", "234567890123456789"],
});
const diagnostics = useConnectionDiagnostics();
// group.data.value?.presences; diagnostics.value.modeusePresences returns { data, loading, error, refresh }; useConnectionDiagnostics returns a single readonly-style reactive diagnostics ref. Client-side subscriptions must have access to the browser.
Was this page helpful?