/docs/getting-started/iframe-init
Initialize Canvas
Embed the Canvas iframe and dispatch the first view payload.
Set the Canvas URL, mount the iframe, and send a view message once it loads.
- Keep the viewer origin and URL in a single configuration module.
- Wait for the iframe load event before posting messages.
- Send a `view` payload with a file URL to bootstrap the session.
Define the Canvas URL once and reuse it across viewer sessions.
javascript
Define the Canvas URL
Create the iframe, attach it to the DOM, and wait for the load event before sending messages.
javascript
Initialize the iframe
Reuse a typed payload shape to keep viewer messages consistent.
typescript
Type the payload (TypeScript)
Use progressStart and progressEnd to drive loading UI while the viewer prepares files.
javascript
Handle progress events
A full example with configuration, iframe lifecycle, and the initial view message.
javascript
Complete Implementation
