Getting page information

How to get information about the current page.

The Design Interaction capability exposes a getCurrentPageContext method. You can use this method to get information about the current page of the user's design:

const context = await getCurrentPageContext();

Dimensions

To get the dimensions of the current page, access the dimensions property:

console.log(context.dimensions); // => { width: 1280, height: 720 }

A use-case for a page's dimensions is to position elements relative to the bounds of the current page. For example, positioning an element X pixels from the right edge and Y pixels from the bottom edge.