Skip to content

API Documentation

Complete API reference for stx templating engine and its packages.

Core APIs

Template Processing

Data & State

Styling & UI

Development

Package APIs

Content Processing

  • Markdown - Markdown file processing and @markdown-file directive
    • 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

Internationalization

  • i18n - Internationalization and localization
    • @translate directive
    • Multiple file formats (JSON, YAML, JS)
    • Parameter substitution
    • Dynamic locale switching

Advanced APIs

Routing & Plugins

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],
})

See Also

Released under the MIT License.