🧩 Plasmo Developers�PD
🧩 Plasmo Developers3y ago
18 replies
Avi

Send message from popup to cs and back

I have something like:
content.ts
chrome.runtime.onMessage.addListener((_, __, sendResponse) => {
  sendResponse(...)
});

popup.svelte
<script lang="ts">
  chrome.tabs.query({ active: true, currentWindow: true }, ({ tabs: { 0: { id } } }) => {
    chrome.tabs.sendMessage(id, value => {
      // ...
    });
  });
</script>

but I keep getting on the popup
Unchecked runtime.lastError: The message port closed before a response was received.
Was this page helpful?