Luminara Plugins
November 18, 2025 ยท View on GitHub
Luminara's plugin system allows you to extend the HTTP client with additional functionality through a simple, hooks-based API.
๐ ๏ธ Creating Custom Plugins
Luminara uses an enhanced interceptor system with three lifecycle hooks:
const myPlugin = {
name: 'my-plugin',
// Called when plugin is registered
onAttach(client) {
// Attach custom properties or methods to client
client.myCustomMethod = () => console.log('Hello!');
},
// Called before each request (with retry context)
onRequest(context) {
// context = { req, res, error, attempt, maxRetries, statsHub, client, ... }
// Modify context.req directly
context.req.headers = context.req.headers || {};
context.req.headers['X-Custom'] = 'value';
},
// Called after successful response
onResponse(context) {
// Transform response
context.res.data.transformed = true;
},
// Called on response error (can trigger retry)
onResponseError(context) {
// Handle errors
if (shouldRetry) throw context.error; // Triggers retry
}
};
const client = createLuminara({
plugins: [myPlugin]
});
Plugin Execution Order
onRequest: Left-to-right (LโR) through plugin arrayonResponse: Right-to-left (RโL) for unwindingonResponseError: Right-to-left (RโL) for error handling
Best Practices
- Use descriptive plugin names for debugging
- Keep plugins focused on a single responsibility
- Handle errors gracefully - plugins shouldn't crash requests
- Document your plugin with examples and API reference
- Test retry compatibility - ensure plugins work across retry attempts
- Use TypeScript for better developer experience (optional)
๐ฆ Publishing Plugins
To publish your Luminara plugin to npm:
- Package naming: Use
luminara-[feature-name]convention - Peer dependencies: Add
luminaraas a peer dependency - Documentation: Include comprehensive README with examples
- Testing: Write tests for plugin functionality
- TypeScript: Include type definitions if applicable
Example package.json:
{
"name": "luminara-my-plugin",
"version": "1.0.0",
"peerDependencies": {
"luminara": ">=1.0.0"
}
}
๐ค Contributing Plugins
Have you created a useful Luminara plugin? We'd love to feature it here!
Open a pull request to add your plugin to this documentation, or reach out via:
- GitHub: luminara repository
- Author: Jonathan Miller