Frameworks
@skyscribe-sdk/core is plain TypeScript with no runtime dependencies. It works in any environment: Node.js, Deno, Bun, browsers, edge functions, or any other JavaScript runtime.
Every framework adapter is a thin wrapper around this package. If your framework isn't listed, or you'd rather manage state yourself, use @skyscribe-sdk/core directly.
npm install @skyscribe-sdk/core
import { fetchPublication } from '@skyscribe-sdk/core';
const publication = await fetchPublication('alice.bsky.social', 'https://alice.bsky.social');
console.log(publication.name);
console.log(publication.description);
console.log(publication.domain); // e.g. "alice.bsky.social"
console.log(publication.basePath); // e.g. "blog" or ""
for (const category of publication.categories) {
for (const ref of category.documents) {
console.log(ref.title, ref.slug, ref.description);
}
}
Look a Document up by its slug, which is what appears in your URLs:
import { fetchDocumentBySlug } from '@skyscribe-sdk/core';
const document = await fetchDocumentBySlug(
'alice.bsky.social',
'https://alice.bsky.social',
'my-first-post',
);
console.log(document.title);
console.log(document.description);
console.log(document.content); // Full HTML
console.log(document.createdAt);
If you already have a DocumentRef, fetchDocument skips the Publication lookup. It takes the account and record key (rkey), both found in the ref's AT URI (at://{did}/site.standard.document/{rkey}). Take the account from there rather than assuming the Publication owner's: a Document credited to a contributor can live in their account.
import { fetchDocument, slugFromUri } from '@skyscribe-sdk/core';
const ref = publication.categories[0].documents[0];
const document = await fetchDocument(ref.uri.split('/')[2], slugFromUri(ref.uri));
Careful
Don't pass a slug to fetchDocument: Documents published with current tooling have opaque rkeys like 3mp47vvkh342n, so a slug only finds very old Documents. Use fetchDocumentBySlug when you have a slug.
Before rendering document.content, read Rendering the HTML: if you show Documents from accounts you don't control, sanitise it first.
import { slugFromUri, flattenDocuments } from '@skyscribe-sdk/core';
// The last segment of an AT URI: the record's rkey
slugFromUri('at://did:plc:abc/site.standard.document/3mp47vvkh342n') // → "3mp47vvkh342n"
// All published Documents across all Categories, in order
const allDocuments = flattenDocuments(publication.categories);
Every fetch function accepts an optional AbortSignal as its last argument:
// On the server: cancel if the visitor navigates away
const publication = await fetchPublication(author, 'https://alice.bsky.social', request.signal);
// In the browser: cancel on unmount or when parameters change
const controller = new AbortController();
const publication = await fetchPublication(author, 'https://alice.bsky.social', controller.signal);
controller.abort();
Tip
The framework adapters wire up cancellation for you. You only manage signals yourself when using @skyscribe-sdk/core directly.
Show the Publication's owner visit figures on its Insights tab in SkyScribe (free, cookie-free):
// In the browser, once per page
import { loadSiteAnalytics } from '@skyscribe-sdk/core';
loadSiteAnalytics();
// Or print the tag into server-rendered HTML
import { siteAnalyticsScriptTag } from '@skyscribe-sdk/core';
Figures only appear once your website serves the Publication verification file. See the Site Analytics guide for that, privacy, and CSP.
import type { StandardPublication, StandardDocument, DocumentRef, Category } from '@skyscribe-sdk/core';
See the API reference for the full type definitions.