API reference
All exports from fromsrc
fromsrc exports from two entry points:
fromsrc- server utilities and content helpersfromsrc/client- React components and hooks
fromsrc
Server-side utilities for content loading.
Functions
| prop | type |
|---|---|
getDoc? | (dir, slug[]) => Promise<Doc | null> |
getAllDocs? | (dir) => Promise<DocMeta[]> |
getNavigation? | (dir) => Promise<Section[]> |
defineContent? | (config) => ContentAPI |
defineCollection? | (config) => Collection |
defineCollections? | (configs) => Record<string, Collection> |
API utilities
| prop | type |
|---|---|
json? | (data, status?, headers?) => Response |
error? | (message, status?) => Response |
cors? | (config?) => Record<string, string> |
withCors? | (response, config?) => Response |
cache? | (response, maxAge, stale?) => Response |
rateLimiter? | (config) => (key) => { allowed; remaining; resetAt } |
rateLimiter stores counters in process memory. Use a shared store for multi-instance deployments.
cors() defaults to wildcard origins when no explicit origins are provided. Pass origins in production APIs.
Schema utilities
| prop | type |
|---|---|
baseSchema? | ZodObject |
defineSchema? | (schema) => schema |
extendSchema? | (fields) => ZodObject |
z? | typeof zod |
Types
fromsrc/client
React components for building documentation UI.
Layout components
| component | description |
|---|---|
| Sidebar | navigation sidebar with sections and folders |
| MobileNav | mobile navigation drawer |
| Breadcrumb | breadcrumb navigation |
| Toc | table of contents sidebar |
| TocInline | inline table of contents |
Content components
| component | description |
|---|---|
| CodeBlock | syntax highlighted code with copy button |
| CodeGroup | tabbed code blocks |
| Callout | info, warning, error, tip callouts |
| Steps | numbered step lists |
| Tabs | tabbed content panels |
| Cards | grid of linked cards |
| Accordion | collapsible sections |
| Files | file tree display |
| TypeTable | API property documentation |
Utility components
| component | description |
|---|---|
| Badge | inline badges |
| Banner | dismissible banners |
| Link | external link with icon |
| Zoom | image lightbox |
| Tooltip | hover tooltips |
| Github | GitHub repo info |
| Video | embedded video |
| Mermaid | Mermaid diagrams |
| ThemeToggle | light/dark mode toggle |
| BackToTop | scroll to top button |
Hooks
| prop | type |
|---|---|
useToc? | () => TocState |
useKeyboardNav? | (docs) => void |
useCopy? | (duration?) => { copied, copy } |