Quickstart

Get an app up and running in a matter of minutes.

Canva's app development platform allows anyone to create apps that enhance Canva. This guide explains how to get an app up and running in a matter of minutes.

To follow this guide, you'll need to:

  • Sign up for a Canva.com account.
  • Install git, Node.js v20.10.0, and npm v10.
  • Learn the fundamentals of TypeScript, React, and webpack.

If you need help with any of these prerequisites, including how to set up the required tooling, see Prerequisites. If you need help with the Canva CLI, use the --help flag for more information.

  1. Install the Canva CLI globally:

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

    canva login
    shell
  3. Click Allow to grant the Canva CLI permission to manage your Canva apps.

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

  5. Run the canva apps create command to start the app creation process, or run the command with the following optional command flags. If they aren't set, the Canva CLI prompts you for a decision during the app creation process:

    • App name: Add your app's name after the canva apps create command as an argument. For example: canva apps create "A New App".

    • App template: Select a template using the --template flag. You can select one of these templates:

    • Audience: Set the target audience using the --distribution flag. This flag is important because it restricts the target audience for your app:

      • public: You can make your app available to all of Canva's users, but the app will need to be reviewed by Canva and meet the requirements outlined in the submission checklist.
      • private: The app can only be made available to members of the current team, and the team's administrators are responsible for reviewing it.
    • Git: Include a Git repository using the --git flag.

    • Dependencies: Install dependencies during the app creation process using the --installDependencies flag.

This example creates an app named "My New App" that uses the hello_world template with public distribution, includes a Git repository, and installs the dependencies during the app creation process:

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

When the build process is complete, the Canva CLI automatically opens the Developer Portal to your new app's configuration page.

  1. Change into the app's folder:

    cd my-new-app
    shell
  2. If you did not use the --installDependencies flag when running the canva apps create command, or install the dependencies when prompted, manually install the dependencies:

    npm install
    shell
  3. Run the npm command to start your app:

    npm start
    shell

    The local development server starts running at http://localhost:8080, but you can't use this URL to view the local preview, see the next step instead.

This step explains how to use Canva to view the app running locally at http://localhost:8080.

  1. In the Developer Portal, navigate to the app’s Configure your app page.
  2. Select App source > Development URL.
  3. In the Development URL field, enter the URL of the development server.
  4. Click Preview to open the app in a preview Canva editor.
  5. Click Open If this is the first time previewing your app.

The example app includes a button that responds with "Hello world!" when clicked:

Preview of the app running locally, with a button saying "Do something cool"

To learn more about how to preview apps, including how to set up live reloading, see Previewing apps.

Use a code editor to open src/app.tsx. This file contains placeholder code that you can edit to start building your app.

In the following example, a button click triggers a wrapper method for addElementAtPoint, adding a new text layer to the Canva design with the words "Hello world!".

import { Button, Rows, Text } from "@canva/app-ui-kit";
import { FormattedMessage, useIntl } from "react-intl";
import * as styles from "styles/components.css";
import { useAddElement } from "utils/use_add_element"; // https://github.com/canva-sdks/canva-apps-sdk-starter-kit/blob/main/utils/use_add_element.ts
export const App = () => {
const addElement = useAddElement();
const onClick = () => {
addElement({
type: "text",
children: ["Hello world!"],
});
};
const intl = useIntl();
return (
<div className={styles.scrollContainer}>
<Rows spacing="2u">
<Text>
<FormattedMessage
defaultMessage="
To make changes to this app, edit the <code>src/app.tsx</code> file,
then close and reopen the app in the editor to preview the changes.
"
description="
Instructions for how to make changes to the app. Do not translate
<code>src/app.tsx</code>.
"
values={{
code: (chunks) => <code>{chunks}</code>,
}}
/>
</Text>
<Button variant="primary" onClick={onClick} stretch>
{intl.formatMessage({
defaultMessage: "Do something cool",
description:
"Button text to do something cool. Creates a new text element when pressed.",
})}
</Button>
</Rows>
</div>
);
};
tsx

When you log in to the Canva CLI using the canva login command, the Canva CLI generates an authentication token. The token prevents you from having to repeat an authentication step for every CLI request. The token is encrypted and stored in ~/.canva-cli/credentials or %USERPROFILE%\.canva-cli\credentials, depending on your operating system.

You can use the canva logout command to revoke the token's access to your account as well as deleting the token file. Manually deleting the token file removes Canva CLI access, but doesn't revoke the token, so a copy of the token could reconnect the Canva CLI to your account.

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

canva logout
shell