On September 25th, 2024, we released v2 of the Apps SDK. To learn what’s new and how to upgrade, see Migration FAQ and Migration guide.

getCurrentPageContext

API reference for the getCurrentPageContext method.
This version of the API is deprecated. This version will soon be unsupported. You should use a stable version of the API in your app.

Gets information about the current page in the user's design.

To see how this method is used, see Positioning elements.

Usage

import { getCurrentPageContext } from "@canva/design";
const context = await getCurrentPageContext();
console.log(context);
TS

Permissions

Before an app that uses this method can be submitted for review, the canva:design:content:read permission must be enabled via the Developer Portal. To learn more, see Configuring permissions.

Returns

A Promise that resolves with the following object:

resultobject
REQUIRED

The successful result of getting the current page context.

result.dimensionsobject
OPTIONAL

The dimensions of the page, in pixels.

Some types of designs, such as whiteboards(opens in a new tab or window), 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.