# postMessage from the plugin to a webview panel

**URL:** https://discourse.joplinapp.org/t/postmessage-from-the-plugin-to-a-webview-panel/15327
**Category:** Plugins
**Created:** [4 March 2021 22:33 UTC](https://discourse.joplinapp.org/t/postmessage-from-the-plugin-to-a-webview-panel/15327 "2021-03-04T22:33:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![gvido](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@gvido](https://discourse.joplinapp.org/u/gvido)
#### Post date: [4 March 2021 22:33 UTC](https://discourse.joplinapp.org/t/postmessage-from-the-plugin-to-a-webview-panel/15327/1 "2021-03-04T22:33:22Z")

</div>

Hi!

First of all, props to everyone involved in development of Joplin. It's a pleasure to use, and has become an indispensable tool in my daily life. I recently started working on my first Joplin plugin, and the new plugin API is a pleasure to work with. Great work, thank you!

I'm relatively new to the Joplin codebase, so apologies if I'm missing something obvious, but – is there a way to send data via `postMessage` from a plugin to a webview panel instead of only responding to a message?

My plugin has a command that can be invoked from multiple places. It extracts information from the current note (or multiple notes, or a whole notebook, depending on where it's invoked from), displays the data in a panel for user confirmation and editing, and then sends it off to an external API.

The UI in the webview is built with preact. I would like to keep all data processing in the plugin thread and just send the new data to the webview without re-rendering the whole panel via `panels.setHtml` on every execution.

Thank you!

---

<div class="post-metadata">

### Author: ![roman\_r\_m](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/roman_r_m/32/3297_2.png) [@roman\_r\_m](https://discourse.joplinapp.org/u/roman_r_m)
#### Post date: [4 March 2021 22:44 UTC](https://discourse.joplinapp.org/t/postmessage-from-the-plugin-to-a-webview-panel/15327/2 "2021-03-04T22:44:42Z")

</div>

I guess you can try something like this:

- when your webview loads, send a message to the plugin
- in the plugin return a promise, but do not resolve it, instead store a reference to the promise
- when it's time to send data back to webview, retrieve the promise and resolve it with the data
- repeat

---

<div class="post-metadata">

### Author: ![gvido](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@gvido](https://discourse.joplinapp.org/u/gvido)
#### Post date: [5 March 2021 18:25 UTC](https://discourse.joplinapp.org/t/postmessage-from-the-plugin-to-a-webview-panel/15327/3 "2021-03-05T18:25:31Z")

</div>

Feels like a bit of a hack, but it will have to do 🙂  
Are there security related reasons why it's not possible in a more tidy way?  
Either way, I'll try it out and see how that works, thank you!
