Frameworks
@skyscribe-sdk/nuxt is a full Nuxt 3 module. It registers its composables as auto-imports, and they use useAsyncData, so content is fetched during server rendering and reused on the client.
npm install @skyscribe-sdk/nuxt
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@skyscribe-sdk/nuxt'],
});
That's it: useScribePublication, useScribeDocumentBySlug, useScribeDocument, useScribePublicationUri and useScribeDocumentUri are now available in any component or page without importing them.
useScribePublication<!-- pages/blog/index.vue -->
<script setup lang="ts">
const { data: publication, pending, error } = await useScribePublication(
'alice.bsky.social',
'https://alice.bsky.social'
);
</script>
<template>
<p v-if="pending">Loading…</p>
<p v-else-if="error">Error: {{ error.message }}</p>
<main v-else-if="publication">
<h1>{{ publication.name }}</h1>
<section v-for="category in publication.categories" :key="category.slug">
<h2>{{ category.title }}</h2>
<ul>
<li v-for="ref in category.documents" :key="ref.uri">
<NuxtLink :to="`/blog/${category.slug}/${ref.slug}`">{{ ref.title }}</NuxtLink>
</li>
</ul>
</section>
</main>
</template>
A Document page usually gets the Document's slug from the URL. useScribeDocumentBySlug looks it up in the Publication; data holds the Document (its uri is its AT URI):
<!-- pages/blog/[category]/[slug].vue -->
<script setup lang="ts">
const route = useRoute();
const { data: document, pending, error } = await useScribeDocumentBySlug(
'alice.bsky.social',
'https://alice.bsky.social',
route.params.slug as string,
);
</script>
<template>
<p v-if="pending">Loading…</p>
<p v-else-if="error">Error: {{ error.message }}</p>
<article v-else-if="document">
<h1>{{ document.title }}</h1>
<p v-if="document.description">{{ document.description }}</p>
<div class="scribe-content" v-html="document.content" />
</article>
</template>
If you render Documents from accounts you don't control, sanitise content before passing it to v-html (see Rendering the HTML).
useScribeDocumentuseScribeDocument(author, rkey) fetches a Document by its account and record key (rkey), skipping the Publication lookup. Use it when you already have a DocumentRef: the account is ref.uri.split('/')[2] and the rkey is slugFromUri(ref.uri). Don't pass a slug: Documents published with current tooling have opaque rkeys, so a slug only finds very old Documents.
useAsyncData optionsEvery composable accepts an optional last argument that's passed on to useAsyncData:
const { data: publication } = await useScribePublication('alice.bsky.social', 'https://alice.bsky.social', {
lazy: true, // don't block navigation
server: false, // client-only fetch
});
documentSeoMeta(document, publication) and publicationSeoMeta(publication) return objects ready for Nuxt's useSeoMeta. useSeoMeta has no field for a canonical link, the site.standard link tags or structured data, so add those with useHead, using the re-exported buildCanonicalUrl, standardSiteLinks and generateDocumentJsonLd. See the meta tags guide.
Show the Publication's owner visit figures on its Insights tab in SkyScribe (free, cookie-free):
<!-- Once, in app.vue (auto-imported) -->
<script setup lang="ts">
useSiteAnalytics();
</script>
Figures only appear once your website serves the Publication verification file. See the Site Analytics guide for that, privacy, and CSP.
The main types from @skyscribe-sdk/core are re-exported:
import type { StandardPublication, StandardDocument, DocumentRef, Category } from '@skyscribe-sdk/nuxt';