Outsmartly
Search…
Plugins
Plugins are used to encapsulate and abstract away adding functionality to your Outsmartly edge. They'll often include things like middleware, interceptors, and overrides.
Making your own plugins is possible, but more commonly you'll use one of the existing ones maintained by Outsmartly, or ones from the community:

Common Plugins

Usage

1
import { somePlugin } from '@outsmartly/plugin-something';
2
export default {
3
host: 'example.outsmartly.app',
4
environments: [
5
{
6
name: 'production',
7
origin: 'https://my-example-website.vercel.app',
8
},
9
],
10
plugins: [
11
// Most plugins provide a factory function for passing in options:
12
somePlugin({
13
something: true,
14
}),
15
],
16
};
Copied!

Making Your Own Plugins

Plugins are objects with a name and lifecycle methods.

Example

1
export function myCustomPlugin(options) {
2
return {
3
name: '@yourcompany/outsmartly-plugin-does-something',
4
setup({ config, messageBus }) {
5
// Listening for messages, globally
6
messageBus.on('Something.HAPPENED', async (event) => {
7
const { message } = event;
8
// do something with it, such as call fetch()
9
});
10
11
// Adding custom middleware
12
config.middleware.unshift(async (event, next) => {
13
const response = await next();
14
return response;
15
});
16
17
config.routes.push({
18
path: '/something',
19
async intercept(event) {
20
return new Response('hello, world!');
21
},
22
});
23
},
24
};
25
}
Copied!
Last modified 2mo ago