API Documentation
Complete API reference for stx templating engine and its packages.
Core APIs
Template Processing
- Template Syntax - Directives, expressions, and template syntax
- Component API - Creating and using components
- Components - Built-in components reference
Data & State
- State Management - Application state handling
- Helpers - Helper functions and utilities
- Utilities - Additional utility functions
Styling & UI
- Styling API - Styling components and templates
- TypeScript Integration - Using TypeScript with stx
Development
- CLI Commands - Command line interface reference
- Configuration - Configuration options
- Testing - Testing utilities and functions
Package APIs
Content Processing
- Markdown - Markdown file processing and
@markdown-filedirective- YAML frontmatter support
- Variable substitution
- Server-side syntax highlighting with Shiki
- Programmatic API (
readMarkdownFile,processMarkdownFileDirectives)
Performance & Optimization
- Caching - Template caching system
- Memory and disk caching
- Cache invalidation
- Dependency tracking
- Performance optimization
Error Handling & Debugging
- Error Handling - Error types and recovery
- Custom error types (
StxError,StxSyntaxError,StxRuntimeError, etc.) - Error context and debugging
- Error recovery strategies
- Production error handling
- Custom error types (
Internationalization
- i18n - Internationalization and localization
@translatedirective- Multiple file formats (JSON, YAML, JS)
- Parameter substitution
- Dynamic locale switching
Advanced APIs
Routing & Plugins
- Core API - Core functionality and features
- Plugins - Plugin system and API
- Router - Routing capabilities
Quick Reference
Import Examples
typescript
// Serve API (for documentation systems)
import { serve, createMiddleware, createRoute } from '@stacksjs/stx'
// Markdown processing
import { readMarkdownFile } from '@stacksjs/stx'
// Caching
import { checkCache, cacheTemplate } from '@stacksjs/stx'
// Error handling
import { StxError, StxSyntaxError } from '@stacksjs/stx'
// i18n
import { loadTranslation, getTranslation } from '@stacksjs/stx'
// Template processing
import { processDirectives } from '@stacksjs/stx'Bun Plugin
typescript
import stxPlugin from 'bun-plugin-stx'
await Bun.build({
entrypoints: ['./src/index.stx'],
outdir: './dist',
plugins: [stxPlugin],
})