# Embed custom plugin in another custom plugin

**URL:** https://discuss.elastic.co/t/embed-custom-plugin-in-another-custom-plugin/275165
**Category:** Kibana
**Created:** [June 7, 2021, 2:17pm UTC](https://discuss.elastic.co/t/embed-custom-plugin-in-another-custom-plugin/275165 "2021-06-07T14:17:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jackson123](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@jackson123](https://discuss.elastic.co/u/jackson123)
#### Post date: [June 7, 2021, 2:17pm UTC](https://discuss.elastic.co/t/embed-custom-plugin-in-another-custom-plugin/275165/1 "2021-06-07T14:17:36Z")

</div>

Hi,

I need help in a use case. I am developing two custom plugins (say P1 & P2) . And I want to embed P2 into P1. (May be multiple plugins also).

Can you please help me how to do this?

---

<div class="post-metadata">

### Author: ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)
#### Post date: [June 8, 2021, 5:50pm UTC](https://discuss.elastic.co/t/embed-custom-plugin-in-another-custom-plugin/275165/2 "2021-06-08T17:50:05Z")

</div>

Kibana plugins don't have the concept of extending other plugins directly, but many plugins choose to expose specific extension points to allow other plugins to enhance their functionality.  
What are you trying to develop and achieve?

cc @timroes for more detailed inputs.

---

<div class="post-metadata">

### Author: ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)
#### Post date: [June 8, 2021, 6:37pm UTC](https://discuss.elastic.co/t/embed-custom-plugin-in-another-custom-plugin/275165/3 "2021-06-08T18:37:29Z")

</div>

Hi,

in principal every plugin in the Kibana plugin infrastructure (so called _Kibana Platform_) can expose APIs. An API can be any bit of JavaScript code, thus you can expose e.g. an extension point in P1, that any other plugin can register something into that should be rendered, or your plugins could expose specific components.

You can find an overview of the Kibana platform here: [kibana/kibana\_platform\_plugin\_intro.mdx at master · elastic/kibana · GitHub](https://github.com/elastic/kibana/blob/master/dev_docs/kibana_platform_plugin_intro.mdx)

Also existing Kibana plugins are always a good reference if you need to figure out how to build something. If you can provide more specific details what you mean by "embedding" and the interaction between P1 and P2, I might be able to point you towards better fitting example plugins or Kibana plugins for reference.

Cheers,  
Tim

---

<div class="post-metadata">

### Author: ![jackson123](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@jackson123](https://discuss.elastic.co/u/jackson123)
#### Post date: [June 9, 2021, 5:17am UTC](https://discuss.elastic.co/t/embed-custom-plugin-in-another-custom-plugin/275165/4 "2021-06-09T05:17:11Z")

</div>

Hi,

Thanks for your explanation.  
This is what I am trying to do.

 ![Screenshot (3)](https://us1.discourse-cdn.com/elastic/original/3X/4/8/48eae239933179630fa2c331246ec1b13ca5e9ea.png)  
Here is a simple custom plugin where I added a simple download button to download a file given path.  
And I have another plugin P1, say for now empty and I want to have this action available in P1 without writing the entire code again.  
Pls guide me how to do it.

Thanks

---

<div class="post-metadata">

### Author: ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)
#### Post date: [June 9, 2021, 7:47am UTC](https://discuss.elastic.co/t/embed-custom-plugin-in-another-custom-plugin/275165/5 "2021-06-09T07:47:15Z")

</div>

Hi,

in this case it would make most sense that you return that download method as part of the plugin implementing the download method. Basically the API is whatever you return from the `start` method in your plugin.js/ts file, e.g.

```auto
import { downloadHelper } from './download';

class YourPlugin {

  start() {
    return {
      download: downloadHelper,
    };
  }

}

```

In your plugin that should consume that now, you'll need to make that other plugin a dependency in its `kibana.json` via the `requiredPlugins` key (have a look at any plugin in the Kibana repository under src/plugins/ to get an idea about that file (or check the above linked documentation).

In that case your plugin will now get passed in the API of your other plugin into it's start method as the second parameter, i.e. you'll have something like:

```auto
class ConsumingPlugin {

  start(core, dependencies) {
     // Call this to trigger download API of other plugin:
     dependencies.yourPluginId.download();
  }
}

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 7, 2021, 7:47am UTC](https://discuss.elastic.co/t/embed-custom-plugin-in-another-custom-plugin/275165/6 "2021-07-07T07:47:37Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
