Skip to content

@scribe-atp/react

function useSite(author: string, siteSlug: string): UseSiteResult
interface UseSiteResult {
site: Site | null;
loading: boolean;
error: Error | null;
}

Fetches a site on mount and re-fetches whenever author or siteSlug changes. Aborts the in-flight request on unmount and on parameter change.

ParameterTypeDescription
authorstringAuthor handle or DID
siteSlugstringSite rkey — derive with toSlug(domain)

While loading, site is null and loading is true. On error, site remains null and error is set. AbortError is swallowed and does not set error.


function useArticle(author: string, articleSlug: string): UseArticleResult
interface UseArticleResult {
article: Article | null;
loading: boolean;
error: Error | null;
}

Fetches an article on mount and re-fetches whenever author or articleSlug changes. Aborts on unmount and on parameter change.

ParameterTypeDescription
authorstringAuthor handle or DID
articleSlugstringArticle rkey / slug

toSlug is re-exported for convenience:

import { toSlug } from '@scribe-atp/react';

See toSlug in the core reference for details.


All types from @scribe-atp/core are re-exported:

import type { Site, Article, ArticleRef, SiteGroup } from '@scribe-atp/react';

See the core reference for type definitions.