Launch the Simple Editor on your website
This tutorial walks you through building a small Vanilla TypeScript app that opens the Simple Editor for a configured Customer's Canvas product and submits the customization result for rendering. A small Express backend keeps the OAuth2 client credentials, the access token, and the storefront user token on the server, so the browser receives only the data needed to initialize the editor. The result is a sandbox project for experiments with Customer's Canvas Hub APIs and SDKs.
Prerequisites
- A Customer's Canvas Hub tenant prepared for frontend integration
- The collected
tenantId,storefrontId, OAuth2 client credentials, and a testproductId - A workflow of the Workflow Elements type with the
simple-editorcomponent assigned to the product (see Workflow Elements Overview) - Node.js 18 or later
Set up the project
-
Create a project folder.
mkdir simple-editor-quick-startcd simple-editor-quick-start -
Create a Vite app.
npm create vite@latest . -- --template vanilla-ts -
Install the backend dependencies.
npm install @aurigma/axios-storefront-api-client axios dotenv expressnpm install -D @types/express @types/node concurrently tsx -
Create
vite.config.tsin the project root.import { defineConfig } from "vite";export default defineConfig({server: {host: "127.0.0.1",proxy: {"/api": "http://127.0.0.1:3001",},},});Vite runs on
127.0.0.1and forwards browser requests from/api/*to the local backend. -
Update the
devscript inpackage.json.{"scripts": {"dev": "concurrently vite \"tsx watch server/server.ts\""}}The
devscript starts Vite and the Express backend together. Leave the other Vite scripts unchanged.If you run
npm run devnow, it fails because the backend files don't exist yet.
Configure Customer's Canvas connection
-
Create an
.envfile in the project root. -
Add your Customer's Canvas values.
CCHUB_BASE_URL=https://customerscanvashub.comCCHUB_API_GATEWAY_URL=https://api.customerscanvashub.comCCHUB_TENANT_ID=<tenant_id>CCHUB_STOREFRONT_ID=<storefront_id>CCHUB_CLIENT_ID=<client_id>CCHUB_CLIENT_SECRET=<client_secret>Use the EU or AU URLs when your tenant runs in another region. Keep
CCHUB_CLIENT_SECRETonly on the backend. Do not expose it inVITE_*variables or browser code.