Documentation

Plugin Lifecycle

Understanding how plugins are loaded, initialized, and executed in Frame-Master.

🔄 Lifecycle Overview

Plugins go through distinct phases during the server lifecycle.

1
Initialization
Plugins loaded, sorted by priority, requirements validated
2
Server Startup
serverStart hooks execute, runtime plugins loaded
3
Request Processing
Router hooks handle each HTTP request
4
Build Process
Build hooks customize compilation

📋 Execution Flow

When and how each hook type executes.

// 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.

frame-master.config.ts
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 → logging
Auth0-10
Session/DB10-30
Processing30-60
Logging80-100

✨ Best Practices

Tips for effective lifecycle management.

Keep Hooks Lightweight

Move heavy operations to serverStart.

🔒

Handle Errors

Wrap hook logic in try-catch.

🎯Next Steps