Context Processors API¶
registerContextProcessor¶
Register a context processor function that runs before every render. The returned object is merged into the rendering context, with explicit context values always winning.
Signature¶
-
Receives the
Contextobject, allowing inspection of existing values viacontext.get('key'). -
Must return a plain object. Returning
nullorundefinedis treated as{}. -
Must be synchronous — no async/await or Promises.
clearContextProcessors¶
Clear all registered context processors. Useful in tests or when re-configuring.
Precedence Rules¶
-
Context processors run first — their key/value pairs are added to the context.
-
Your explicit context is applied last — explicit values always override processor values.
// Processor sets: { siteName: 'My App', theme: 'dark' }
// You render with: { theme: 'light' }
// Result: { siteName: 'My App', theme: 'light' }