Composables
Overview
The layer provides composables across core and module locations:
layer/app/composables/— Core composables (content, navigation, forms, storage, social)layer/modules/events/runtime/composables/— Event tracking (useEvents,useUserIdentity)layer/modules/changelog/runtime/composables/— Changelog (useChangelog)layer/modules/docs/runtime/composables/— Docs features (useSearch,useCitations,useGlossary,useSourcesTable)layer/modules/rss/runtime/composables/— RSS feeds (useRssFeed)
All composables are auto-imported by Nuxt. No explicit imports needed.
Event Tracking
useEvents
Core event tracking. Wraps events with userId and timestamp, emits events:track hook for all providers.
const { trackEvent } = useEvents()
await trackEvent({
id: 'email_submit',
type: 'form_submitted',
location: 'hero',
data: { email: '[email protected]' },
})
Returns:
useUserIdentity
Anonymous user identity for cross-session tracking. Uses Web Crypto API. SSR-safe.
const { getUserId } = useUserIdentity()
const userId = getUserId() // Persisted across sessions
Returns:
Content
useContentConfig
Centralized content configuration and path resolution. All collection name/prefix/routing logic lives here.
const { collections, routing, getCollectionForRoute } = useContentConfig()
// Pre-resolved collection names
collections.docs // e.g., 'docs'
collections.pages // e.g., 'pages'
// Routing paths
routing.sources // e.g., '/sources'
routing.offers // e.g., '/offers'
// Dynamic resolution
const collection = getCollectionForRoute('/docs/getting-started')
Returns:
useContentPage
Unified content page composable for route-based collection resolution and page data fetching.
const { collection, getPage, setContext, context } = useContentPage()
// Fetch page for current route
const { data: page } = await getPage()
// Share context with layouts/components
setContext(page.value)
Returns:
useChangelog
Changelog data fetching and author resolution. Provided by the changelog module.
const { items, pending, getAuthorForItem } = useChangelog({
labelField: 'label',
sortField: 'date',
sortOrder: 'DESC',
showAuthor: true,
showImage: true,
})
Returns:
useCitations
Academic citation management per route. Provided by the docs module (requires citations: true).
const { addCitation, getCitationIndex, getReference } = useCitations()
addCitation('smith-2024')
const index = getCitationIndex('smith-2024') // ComputedRef<number>
const ref = getReference('smith-2024') // ComputedRef<Reference>
Returns:
useGlossary
Glossary term fetching and lookup. Provided by the docs module (requires glossary: true).
const { getTerm, resolveGlossaryPath } = useGlossary()
const term = getTerm('mvp') // ComputedRef<TermWithCategory>
const path = resolveGlossaryPath('mvp') // '/glossary?term=mvp'
Returns:
Navigation
useNavigation
Fetches all navigation data from content collections. Async composable.
const { navigationHeader, navigationFooter, banner } = await useNavigation()
Returns:
useSearch
Fetches searchable content sections from configured collections. Async, client-side only. Provided by the docs module (requires search: true).
const { searchFiles } = await useSearch()
Returns:
Forms and Capture
useFormCapture
Form validation, anti-spam, and submission. Extracts all business logic from Form.vue.
const { state, schema, isSubmitting, honeypot, handleSubmit } = useFormCapture({
fields: [{ name: 'email', type: 'email', required: true }],
location: 'hero',
offerSlug: 'free-guide',
})
Returns:
Social
useSocialLinks
Maps a socials config object into link objects with platform-appropriate icons.
const links = useSocialLinks(computed(() => siteConfig.socials))
// [{ icon: 'i-simple-icons-github', to: 'https://github.com/...', label: 'GitHub', target: '_blank' }]
Returns: ComputedRef<SocialLink[]>
useSocialShare
Page sharing with clipboard copy and platform links.
const { menuItems, share, copyLink, copied } = useSocialShare(
computed(() => ({ title: 'My Page', description: 'Check this out' }))
)
Returns:
useRssFeed
RSS feed metadata and feeds page URL. Reads config from rss.feeds in nuxt.config.ts.
const { feeds, feedsPageUrl, trackClick } = useRssFeed()
Returns:
{ name, url, title, description } for each configured feed.offer_click event.Storage
useAppStorage
SSR-safe storage abstraction with config-source prefix.
const { local, session, getKey } = useAppStorage()
local.set('visited', 'true')
local.get('visited') // 'true'
local.all() // All prefixed items
local.clear() // Clear all prefixed items
// Prefixed key
getKey('visited') // 'foundry:visited'
Returns:
get, set, remove, all, clear for localStorage.get, set, remove, all, clear for sessionStorage.Development
useDevConfig
Development-only utilities for inspecting storage state. Returns reduced API in production.
const { clearAllStorage, getStorageSnapshot } = useDevConfig()
// Development only
const snapshot = getStorageSnapshot()
await clearAllStorage() // Clears and reloads
Returns: