Back to TisFile

Embed TisFile Viewer

Add a 3D product customization viewer to your website with a single line of code.

Quick Start

The simplest way to embed TisFile on your website is using an iframe. Just copy this code and add your viewer ID:

<iframe
  src="https://tisfile.com/embed/v/YOUR_VIEWER_ID"
  width="100%"
  height="700"
  frameborder="0"
  allow="fullscreen"
></iframe>

Replace YOUR_VIEWER_ID with your viewer ID from the TisFile Dashboard.

Getting Your Viewer ID

  1. Log in to your TisFile Dashboard
  2. Go to Viewers and select or create a viewer
  3. Find the viewer ID in the embed code snippet at the bottom of the page
  4. Copy the entire iframe code or just the viewer ID

URL Parameters

Customize the viewer appearance using URL parameters:

ParameterDescriptionExample
bgBackground color (hex without #)bg=000000
colorObject/model color (hex without #)color=22d3ee
productPre-select a specific product by IDproduct=abc123

Example with custom colors:

<iframe
  src="https://tisfile.com/embed/v/YOUR_VIEWER_ID?bg=1a1a1a&color=ff6600"
  width="100%"
  height="700"
  frameborder="0"
></iframe>

Domain Allowlist (Security)

For security, you can restrict which domains are allowed to embed your viewer:

  1. Go to your viewer in the TisFile Dashboard
  2. In the Settings section, find Allowed Domains
  3. Add your website domain(s), e.g., https://yourshop.com
  4. Save changes

Security Note

If you leave the allowed domains empty, the viewer can be embedded from any website. For production use, we recommend adding your specific domains.

Wildcard subdomains are supported:

  • https://*.yourshop.com - matches any subdomain
  • http://localhost:3000 - for local development

JavaScript Events (postMessage)

The embedded viewer communicates with your page using the postMessage API. Listen for events to react to user actions:

window.addEventListener('message', (event) => {
  // Verify the origin for security
  if (event.origin !== 'https://tisfile.com') return;

  const { type, viewerId, ...data } = event.data;

  switch (type) {
    case 'tisfile:ready':
      console.log('Viewer is ready', data.products);
      break;
    case 'tisfile:render-complete':
      console.log('STL render completed');
      break;
    case 'tisfile:error':
      console.error('Viewer error:', data.error);
      break;
  }
});

Available Events

Event TypeDescriptionData
tisfile:readyViewer has loaded and is readyproducts, initialProductId
tisfile:render-completeSTL render completed successfullysuccess, hasParts
tisfile:errorAn error occurrederror
tisfile:pongResponse to a ping command-

Responsive Embedding

To make the viewer responsive, wrap the iframe in a container with aspect ratio:

<style>
.tisfile-container {
  position: relative;
  width: 100%;
  padding-bottom: 75%; /* 4:3 aspect ratio */
}
.tisfile-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}
</style>

<div class="tisfile-container">
  <iframe
    src="https://tisfile.com/embed/v/YOUR_VIEWER_ID"
    allow="fullscreen"
  ></iframe>
</div>

Troubleshooting

Embedding Not Allowed Error

If you see "This viewer cannot be embedded on this domain", add your domain to the allowed domains list in your viewer settings.

Viewer Not Loading

Check that your viewer is set to "Active" in the dashboard and has at least one active product with an STL file configured.

Fullscreen Not Working

Make sure to include allow="fullscreen" in your iframe attributes.

Need Help?

Contact our support team or check the full API documentation.