Local development

If you're using the HTML or JavaScript API, it's not possible to add the Canva Button to an HTML file on your local machine and open that file in a web browser. If you do this, you'll encounter a Forbidden (403) error.

This is because Canva expects requests to come from:

  • canva.com

  • localhost

  • a domain on Canva's allowlist

This guide explains how to develop locally by serving an HTML file via localhost.

Step 1: Install http-server

http-server is "a simple, zero-configuration command-line HTTP server." You can use it to make a file (or a directory of files) available via localhost.

You can install http-server via npm or Homebrew.

npm

npm install http-server --global

Homebrew

brew install http-server

You don't have to use http-server to start a local server. There are many other tools that serve a similar purpose.

Step 2: Navigate into the project's directory

Use the cd command to navigate into the directory that contains the HTML file:

cd [dir_path]

Step 3: Start the local server

To start the local server, run the http-server command:

http-server

By default, the local server becomes available at http://localhost:8080.

For a complete list of the arguments and flags that http-server supports, refer to the official documentation.