Composition

Add Canvas

Incorporate a Canvas composition into a front-end application.

info

The code below expects a published version of the composition be available. If the composition is only available in "preview" state, Uniform will return a null composition, which will result in errors.

For more information on composition state, see the glossary. The methods on the CanvasClient also support the ability to retrieve compositions in a specific state (for example, not "published," which is the default value).

  1. Click the Uniform logo at the top of the page to return to the Uniform team home page.

  2. Create an API key with the following custom permissions:

About this step

If you already have an API key with these permissions, you can skip this step.

  1. Add the following values to your .env file. You collected these values when you created the Uniform API key:

    Uniform valueEnvironment variable
    API KeyUNIFORM_API_KEY
    Project IDUNIFORM_PROJECT_ID

About this step

Technically you don't need to set these values in environment variables. You could hard-code the values into your app, but using environment variables is a "best practice."

The changes needed to the front-end depends on the technology used to build the front-end.

To make these instructions easier to follow, a specific example is used. The example activates Canvas for the following page, where the presentation logic in the <main> tag will be controlled by a user with Canvas:

To make these instructions easier to follow, a specific example is used. The example activates Canvas for the following page, where the presentation logic in the <main> tag will be controlled by a user with Canvas: