getCurrentPageContext

API reference for the getCurrentPageContext method.

Returns information about the active page. A page is considered active if it takes up the majority of the viewport or if the user has explicitly selected it.

import { getDesignInteraction } from "@canva/design-interaction";
(async () => {
const designInteraction = getDesignInteraction();
const context = await designInteraction.getCurrentPageContext();
console.log(context);
})();

A Promise that resolves with a result object:

#resultobject
Required

Information about the active page.

#result.dimensionsobject
Optional

The dimensions of the page, in pixels.

Some types of designs, such as whiteboards and documents, don't have page dimensions. In these cases, the dimensions property is undefined.

#result.dimensions.widthnumber
Required

The width of the page, in pixels.

#result.dimensions.heightnumber
Required

The height of the page, in pixels.