Get current PageId inside Extension app

I’m building a simple Extension app and I need current PageId to update custom code through data api. I can’t seem to find any method documented anywhere. Like we have webflow.getSiteInfo() to get siteId, we should also have one for pageId, right?

Can anyone help me with this? @Support_Support @Admin_Developer
I’m aware there’s a html element with data-wf-page attribute but it cannot be accessed from Extension app as it is rendered in an iframe, hence cross-origin blocks it.

Nevermind, I found the answer. We can subscribe to page event.

// Subscribe to changes in the selected page
const selectedPageCallback = (page: Page | null) => {
  if (page) {
    console.log('Selected Page:', page);
  } else {
    console.log('No element is currently selected.');
  }
}

const unsubscribeSelectedElement = webflow.subscribe('currentpage', selectedPageCallback);