@canva/cli

0.0.1-beta.6 • Public • Published

@canva/cli

CLI for creating and managing Canva Apps.

Table of contents

Introduction

@canva/cli is a command line tool designed for creating and managing Canva Apps. Use @canva/cli to get started creating and testing your app. The Canva CLI allows you to create apps from the command line, and to use Canva's recommended development tools and templates.

To learn more about app development, visit the official documentation.

Requirements

Before using the CLI, make sure that you have the following:

  • Node.js v18.20.4 or v20.17.0.

  • npm v9 or v10.

  • A Canva account.

    Note: If you are using a version manager such as nvm, run the nvm install 20.17.0 command to make sure you have the correct Node.js version.

Quickstart

The following commands create a new Canva app using the Canva CLI.

npm install -g @canva/cli@latest
canva login
canva apps create "My New App" --template="hello_world" --distribution="public" --git --installDependencies
cd my-new-app
npm start

Use the Canva CLI

Step 1: Install and log in

Installing the Canva CLI allows you to create new apps from the command line.

To get started:

  1. Install the Canva CLI globally.

    npm install -g @canva/cli@latest
  2. Log in to the Canva CLI. The Canva CLI then opens an access request page in your browser.

    canva login
  3. In your browser, click Allow to grant the Canva CLI access to create and edit apps on your behalf. When you grant access, the Canva CLI generates an auth token and stores it locally. For more information on the auth token, read the following section on auth token storage and removal.

  4. Copy the confirmation code shown in your browser, and paste it into the Canva CLI input.

Step 2: Create your app

After you log in to the Canva CLI and authorize it, you can create your app.

To create a new app:

  1. Run the canva apps create command. The flags in the following code snippet are optional, and you can instead configure these settings during the apps creation process. See the CLI Reference for more information on each flag.

    canva apps create "My New App" --template="hello_world" --distribution="public" --git --installDependencies

    Note: You can't change the distribution type after creating an app.

Step 3: Preview your app

When your new app is ready, the Canva CLI automatically opens the Developer Portal to your new app's Configuration page in your browser. You can then continue to preview and manage your new app.

To preview your app:

  1. Change into your new app's folder.

    cd my-new-app
  2. Run the following command to start your app.

    npm start
  3. In the Developer Portal, click Preview to open the Canva Editor preview.

  4. If this the first time previewing your app, click Open to preview your new app.

Log out, auth token storage, and removal

When you log in to the Canva CLI using the canva login command, and then grant the Canva CLI access to manage apps in your Canva account, an auth token is encrypted and stored locally on your machine. The token provides authentication for future requests so you don't need to grant the Canva CLI access each time it sends a request.

When you log out of the Canva CLI with the canva logout command, the auth token is revoked, and deleted.

Token Location

The auth token is located in your home directory under the .canva-cli folder.

Removing the Token

To delete the token, there are two options. However only the canva logout command revokes and deletes the token. If there's a copy of the token, it's possible to reconnect the Canva CLI to your account's apps using the token.

Log out

  1. Use the canva logout command to revoke access and delete the stored token.

    canva logout

Delete the file manually

  1. Locate the credentials file, which is stored in the following locations:

    • macOS and Linux: The token is stored in ~/.canva-cli/credentials.
    • Windows: The token is stored in %USERPROFILE%\.canva-cli\credentials.
  2. Delete the file.

CLI Reference

After installation, you can use the Canva CLI by running:

canva <command-name>

Flags

Top-level flags applicable to commands:

  • --help: Show help information about commands and flags.
  • --lite: Enable a simplified CLI interface for enhanced accessibility.
  • --version: Show the CLI version number.

Commands

welcome

Show the welcome page and general information.

canva welcome

tip

Print a random development tip for working with the Apps SDK.

canva tip
  • Aliases:
    • tips: Also prints a random development tip.

login

Log in to the Canva CLI.

canva login

logout

Log out of the Canva CLI, and delete the saved auth token:

canva logout

apps

Manage your Canva apps.

canva apps

apps sub-commands

  • create "app-name": Create a new Canva app.

    canva apps create "My New App" --template="hello_world" --distribution="public" --git --installDependencies
    • Arguments:

      • --name: Sets the app's name. Provide the name you want for the app.
    • Flags:

      • --template: Specifies the starting template for the app.

        Available templates:

        • "hello_world": Basic starting point.
        • "dam": Digital asset management integration.
        • "gen_ai": Generative AI app creation.
      • --distribution: Sets the app's distribution type.

        Available types:

        • "public": Available to all Canva users, subject to Canva review.

        • "private": Only available to your team, and requires team admin approval.

          Note: You can't change the distribution setting after creating a new app with the canva apps create command.

      • --git: Initializes a Git repository in the project directory.

      • --installDependencies: Automatically installs necessary npm dependencies during the app creation process.

      • --offline: Scaffold the app locally without also creating an app in the Developer Portal.

  • list: List all Canva apps.

    canva apps list

logout

Log out and revoke Canva CLI access.

canva logout

Next Steps

Limitations

You must manage your new app created through the Canva CLI through the Developer Portal. You can't manage apps completely through the Canva CLI.

Updates

To update the CLI to the latest version, run:

npm update -g @canva/cli@latest

Contributions

Currently the Canva CLI doesn't accept third-party contributions. Please submit any feature requests through the Canva Developers Community.

License

Refer to the LICENSE.md file for more information.

Package Sidebar

Install

npm i @canva/cli

Weekly Downloads

74

Version

0.0.1-beta.6

License

SEE LICENSE IN LICENSE.md

Unpacked Size

1.28 MB

Total Files

117

Last publish

Collaborators

  • canva-dev