The Canva Button is only available for users in China. If your users aren't in China, you can't use the Canva Button. There are no plans to make the Canva Button available outside of China.

Creating designs

Create a new design with the JavaScript API.

After setting up the JavaScript API, the next step is to allow users to create a design with the Canva editor.

To do this, call the createDesign method:

api.createDesign({
design: {
type: "Poster",
},
});
JAVASCRIPT

At a minimum, the createDesign method expects an opts.design.type argument. This argument defines the design type of a newly created design. The design type determines:

  • The dimensions of the user's design.
  • The templates that Canva shows to the user.

For a complete list of design types that Canva supports, refer to Design types.

Example

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Canva Button</title>
<script src="https://sdk.canva.com/designbutton/v2/api.js"></script>
</head>
<body>
<button>Create a new design</button>
<script type="text/javascript">
(async () => {
if (!window.Canva || !window.Canva.DesignButton) {
return;
}
const api = await window.Canva.DesignButton.initialize({
apiKey: "API KEY GOES HERE",
});
const button = document.querySelector("button");
button.onclick = () => {
api.createDesign({
design: {
type: "Poster",
},
});
};
})();
</script>
</body>
</html>
MARKUP