# Passing data into KIbana iframe state and accessing it via a plugin

**URL:** <https://discuss.elastic.co/t/passing-data-into-kibana-iframe-state-and-accessing-it-via-a-plugin/235768>\
**Category:** Kibana\
**Created:** [June 4, 2020, 1:35pm UTC](https://discuss.elastic.co/t/passing-data-into-kibana-iframe-state-and-accessing-it-via-a-plugin/235768 "2020-06-04T13:35:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gurtgurt](https://avatars.discourse-cdn.com/v4/letter/g/7993a0/32.png) [@gurtgurt](https://discuss.elastic.co/u/gurtgurt)\
**Post date:** [June 4, 2020, 1:35pm UTC](https://discuss.elastic.co/t/passing-data-into-kibana-iframe-state-and-accessing-it-via-a-plugin/235768/1 "2020-06-04T13:35:42Z")

</div>

Hi

I've got a pretty basic Kibana plugin that is running on the client side (no server side logic), and I have a Kibana visualization inside of an iframe. In the parent, I have some values that I would like the plugin to be able to access. These values will only be set once on initialization of the iframe.

Is there a way to set some global state in Kibana on load and access it via a client side plugin at some later time?

I came across this thread which seems promising but out of date: [Kibana Plugins: Using \_g and \_a in URL to pass state](https://discuss.elastic.co/t/kibana-plugins-using-g-and-a-in-url-to-pass-state/137095) is there an updated way to do this in Kibana 7+

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Vadims\_Daleckis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vadims_daleckis/32/57613_2.png) [@Vadims\_Daleckis](https://discuss.elastic.co/u/Vadims_Daleckis)\
**Post date:** [June 5, 2020, 11:10am UTC](https://discuss.elastic.co/t/passing-data-into-kibana-iframe-state-and-accessing-it-via-a-plugin/235768/2 "2020-06-05T11:10:23Z")

</div>

Hi @gurtgurt,

My understanding is you have Kibana running in an `<iframe>` and you would like to pass some data to that `<iframe>`. Maybe you could use [`Window.postMessage()` API](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) to communicate between your parent window and Kibana.

---

<div class="post-metadata">

**Author:** ![gurtgurt](https://avatars.discourse-cdn.com/v4/letter/g/7993a0/32.png) [@gurtgurt](https://discuss.elastic.co/u/gurtgurt)\
**Post date:** [June 5, 2020, 11:43am UTC](https://discuss.elastic.co/t/passing-data-into-kibana-iframe-state-and-accessing-it-via-a-plugin/235768/3 "2020-06-05T11:43:26Z")

</div>

Pretty good idea, I don't know how I didn't stumble on that in my research!  
I guess my fear with using that would be how long MessageEvents are persisted on the target windows queue.  
Basically the parent frame will load the kibana iframe and most likely end up calling `Window.postMessage()` before the Kibana plugin event listener fully instantiated. Do you know if it it still consume the message after the plugin is instantiated?

---

<div class="post-metadata">

**Author:** ![Vadims\_Daleckis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vadims_daleckis/32/57613_2.png) [@Vadims\_Daleckis](https://discuss.elastic.co/u/Vadims_Daleckis)\
**Post date:** [June 6, 2020, 8:37am UTC](https://discuss.elastic.co/t/passing-data-into-kibana-iframe-state-and-accessing-it-via-a-plugin/235768/4 "2020-06-06T08:37:14Z")

</div>

@gurtgurt I don't think the `.postMessage()` messages are queued. What you could do is when your plugin instantiates it would send a message to the parent window. Then parent window would know that the plugin is ready and send the data to the `<iframe>`.

---

<div class="post-metadata">

**Author:** ![gurtgurt](https://avatars.discourse-cdn.com/v4/letter/g/7993a0/32.png) [@gurtgurt](https://discuss.elastic.co/u/gurtgurt)\
**Post date:** [June 6, 2020, 9:28am UTC](https://discuss.elastic.co/t/passing-data-into-kibana-iframe-state-and-accessing-it-via-a-plugin/235768/5 "2020-06-06T09:28:13Z")

</div>

I think that could work.

As another solution, are you aware if there is an updated to pass global and application state into a kibana plugin via the `_g` and `_a` query parameters in Kibana 7+? The current Kibana iframe we are presenting already passes those in to get things like time filters added. The link I added in the original post discusses accessing those states via an angular service that was supposed to be (maybe already is?) deprecated

---

<div class="post-metadata">

**Author:** ![Vadims\_Daleckis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vadims_daleckis/32/57613_2.png) [@Vadims\_Daleckis](https://discuss.elastic.co/u/Vadims_Daleckis)\
**Post date:** [June 15, 2020, 12:35pm UTC](https://discuss.elastic.co/t/passing-data-into-kibana-iframe-state-and-accessing-it-via-a-plugin/235768/6 "2020-06-15T12:35:20Z")

</div>

The `_g` and `_a` URL variables still exist in Kibana. But the structure of those objects can change any time and Kibana might even decide to remove those in the future. So, although you can use now `_g` and `_a`, those URL variables are internal implementation detail of Dashboard and Discover apps.

---

<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 13, 2020, 12:35pm UTC](https://discuss.elastic.co/t/passing-data-into-kibana-iframe-state-and-accessing-it-via-a-plugin/235768/7 "2020-07-13T12:35:38Z")

</div>

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