API reference
Composables for Vue 3. Install with npm install @skyscribe-sdk/vue. See the Vue guide for walkthroughs.
All five composables take plain values, fetch once when called, and abort when the component unmounts. They don't re-fetch if the values change.
SiteAnalyticsconst SiteAnalytics: DefineComponent<{ disabled?: boolean }>
Adds the Site Analytics beacon to the page when mounted. Render it once, in App.vue; it renders nothing itself. disabled leaves the beacon out. On Nuxt, prefer useSiteAnalytics, which puts the tag in the server-rendered HTML.
<script setup lang="ts">
import { SiteAnalytics } from "@skyscribe-sdk/vue";
</script>
<template>
<SiteAnalytics />
</template>
useScribePublicationfunction useScribePublication(author: string, publicationUrl: string): UseScribePublicationResult
interface UseScribePublicationResult {
publication: Ref<StandardPublication | null>;
loading: Ref<boolean>;
error: Ref<Error | null>;
}
Fetches a Publication when called and aborts the request when the component unmounts. Returns reactive refs.
| Parameter | Type | Description |
|---|---|---|
author | string | Author handle or DID |
publicationUrl | string | The Publication's canonical HTTPS URL, e.g. "https://alice.bsky.social" |
While loading, publication.value is null and loading.value is true. On error, error.value is set. A cancelled request doesn't set error.
useScribeDocumentBySlugfunction useScribeDocumentBySlug(
author: string,
publicationUrl: string,
documentSlug: string
): UseScribeDocumentBySlugResult
interface UseScribeDocumentBySlugResult {
document: Ref<StandardDocument | null>; // document.value.uri is its AT URI
loading: Ref<boolean>;
error: Ref<Error | null>;
}
Looks a Document up by its slug in the Publication at publicationUrl (using fetchDocumentBySlug). Aborts on unmount.
| Parameter | Type | Description |
|---|---|---|
author | string | Author handle or DID |
publicationUrl | string | The Publication's canonical HTTPS URL |
documentSlug | string | The Document's slug, as in its URL |
useScribeDocumentfunction useScribeDocument(author: string, rkey: string): UseScribeDocumentResult
interface UseScribeDocumentResult {
document: Ref<StandardDocument | null>;
loading: Ref<boolean>;
error: Ref<Error | null>;
}
Fetches a Document by its record key (rkey) when called, and aborts on unmount. Returns reactive refs.
| Parameter | Type | Description |
|---|---|---|
author | string | Handle or DID of the account the Document is stored in |
rkey | string | The Document's record key |
Take both from a DocumentRef: the account is ref.uri.split('/')[2] and the rkey is slugFromUri(ref.uri). Don't pass a slug: it only finds very old Documents. With a slug, use useScribeDocumentBySlug.
useScribePublicationUrifunction useScribePublicationUri(
author: string,
publicationUrl: string
): UseScribePublicationUriResult
interface UseScribePublicationUriResult {
uri: Ref<string | null>;
loading: Ref<boolean>;
error: Ref<Error | null>;
}
Resolves just the AT URI of a Publication (using resolvePublicationUri from @skyscribe-sdk/core), without returning the whole StandardPublication. Aborts on unmount.
| Parameter | Type | Description |
|---|---|---|
author | string | Author handle or DID |
publicationUrl | string | The Publication's canonical HTTPS URL |
Use it when the AT URI is all you need, for example for your own subscribe UI.
useScribeDocumentUrifunction useScribeDocumentUri(
author: string,
publicationUrl: string,
documentSlug: string
): UseScribeDocumentUriResult
interface UseScribeDocumentUriResult {
uri: Ref<string | null>;
loading: Ref<boolean>;
error: Ref<Error | null>;
}
Resolves just the AT URI of a Document, looked up by its slug (it uses fetchDocumentBySlug and keeps only the uri). Aborts on unmount.
| Parameter | Type | Description |
|---|---|---|
author | string | Author handle or DID |
publicationUrl | string | The Publication's canonical HTTPS URL |
documentSlug | string | The Document's slug, as in its URL |
Use it when the AT URI is all you need, for example for your own like UI.
The main types from @skyscribe-sdk/core are re-exported, along with each composable's result type:
import type { StandardPublication, StandardDocument, DocumentRef, Category } from '@skyscribe-sdk/vue';
See the core reference for type definitions.
useScribeSite (returning site), useScribeArticle (article) and useScribeArticleBySlug (article and uri) still work, marked @deprecated, until the next major. See Upgrading to 5.0.