Plugin Lifecycle
Understanding how plugins are loaded, initialized, and executed in Frame-Master.
🔄 Lifecycle Overview
Plugins move through distinct phases:
- Initialization — Plugins loaded, sorted by priority, requirements validated
- Server Startup —
serverStarthooks execute, runtime plugins loaded - Request Processing — Router hooks handle each HTTP request
- Build Process — Build hooks customize compilation
📋 Execution Flow
// Server Start (once)
serverStart.main() → serverStart.dev_main()
// Each Request
before_request → request → after_request → html_rewrite → global_value_injection
// Build
buildConfig → beforeBuild → [Bun Build] → afterBuild📊 Priority Order
Lower priority numbers execute first.
export default defineConfig({
plugins: [
logging(), // priority: 100 → runs last
reactSSR(), // priority: 50 → runs mid
session(), // priority: 10 → runs second
auth(), // priority: 0 → runs first
],
}); // Order: auth → session → reactSSR → loggingRecommended ranges:
- Auth: 0–10
- Session/DB: 10–30
- Processing: 30–60
- Logging: 80–100
✨ Best Practices
- ⚡ Keep hooks lightweight; push heavy work to
serverStart - 🔒 Handle errors with try-catch; fail gracefully
🎯 Next Steps
- Plugin Hooks — Complete reference for all hooks
- Creating Plugins — Build your own plugins
- Build System — Deep dive into build lifecycle
