useSites
Manage published sites — list, create, stage files, publish to CDN, and delete.
import { useSites } from 'flowstack-sdk'Published site management — list, create, stage files, publish to CDN, delete.
There are two publishing workflows: quick publish (pass files inline to createSite) and staged publish (create an empty site, addFile incrementally, then publishSite).
Signature
const { sites, isLoading, error, createSite, addFile, publishSite, deleteSite, refreshSites } = useSites()Returns
| Field | Type | Description |
|---|---|---|
sites | PublishedSiteInfo[] | The published sites. |
isLoading | boolean | Request in flight. |
error | string | null | Last error message. |
createSite | (params: CreateSiteParams) => Promise<PublishedSiteInfo | null> | Create a site (optionally with inline files). |
addFile | (siteId, path, content) => Promise<boolean> | Stage a file onto an existing site. |
publishSite | (siteId) => Promise<PublishedSiteInfo | null> | Publish a staged site to the CDN. |
deleteSite | (siteId) => Promise<boolean> | Delete a site. |
refreshSites | () => Promise<void> | Re-fetch the site list. |
Examples
Hook surface
const {
sites, // PublishedSiteInfo[]
isLoading, // boolean
error, // string | null
createSite, // (params: CreateSiteParams) => Promise<PublishedSiteInfo | null>
addFile, // (siteId, path, content) => Promise<boolean>
publishSite, // (siteId) => Promise<PublishedSiteInfo | null>
deleteSite, // (siteId) => Promise<boolean>
refreshSites, // () => Promise<void>
} = useSites();Two publishing workflows
// Quick publish — pass files inline
await createSite({
name: 'My Dashboard',
siteType: 'on_demand',
files: { 'index.html': '<html>...</html>', 'styles.css': 'body { ... }' },
});
// Staged publish — add files incrementally, then publish
const site = await createSite({ name: 'My App' });
await addFile(site.id, 'index.html', '<html>...</html>');
await addFile(site.id, 'src/App.tsx', 'export default function App() { ... }');
await publishSite(site.id);NotePublishedSiteInfo fields:
id (string) site ID; name (string) display name; url (string) published CDN URL; shortUrl (string?) short URL for sharing; siteType ('on_demand' | 'daily' | 'js_build') how the site was created; fileCount (number) number of files; totalBytes (number?) total size; createdAt (string) ISO timestamp; expiresAt (string?) expiration if applicable.Source: README.md#usesites · Also available in llms-full.txt and registry.json.