Generate barcodes in different sizes and colours in Canva! This app supports the following barcodes:
v18
(npm v9) or higherNote: To make sure you're running the correct version of Node.js, we recommend using a version manager, such as nvm. The .nvmrc file in the root directory of this repo will ensure the correct version is used.
git clone git@github.com:Dylan700/CanvaBarcodeGenerator.git
cd canva-apps-sdk-starter-kit
npm install
The src
directory contains the boilerplate of an app.
To start the boilerplate's development server, run the following command:
npm start
The server becomes available at http://localhost:8080.
The app's source code is in the src/app.tsx
file.
The local development server only exposes a JavaScript bundle, so you can't preview an app by visiting http://localhost:8080. You can only preview an app via the Canva editor.
To preview an app:
The app will appear in the side panel.
By default, every time you make a change to an app, you have to reload the entire app to see the results of those changes. If you enable Hot Module Replacement (HMR), changes will be reflected without a full reload, which significantly speeds up the development loop.
Note: HMR does not work while running the development server in a Docker container.
To enable HMR:
Navigate to the Your apps page.
Copy the ID of an app from the App ID column.
In the starter kit's .env
file:
CANVA_APP_ID
to the ID of the app.CANVA_HMR_ENABLED
to TRUE
.For example:
CANVA_APP_ID=AABBccddeeff
CANVA_BACKEND_PORT=3001
CANVA_FRONTEND_PORT=8080
CANVA_BACKEND_HOST=http://localhost:3001
CANVA_HMR_ENABLED=TRUE
Restart the local server.
By default, the development server is not HTTPS-enabled. This is convenient, as there's no need for a security certificate, but it prevents apps from being previewed in Safari.
To preview apps in Safari:
Start the development server with HTTPS enabled:
# Run the main app
npm start --use-https
# Run an example
npm start <example-name> --use-https
Navigate to https://localhost:8080.
Bypass the invalid security certificate warning:
In the Developer Portal, set the app's Development URL to https://localhost:8080.
You need to bypass the invalid security certificate warning every time you start the local server. A similar warning will appear in other browsers (and will need to be bypassed) whenever HTTPS is enabled.