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
- Log in to your TisFile Dashboard
- Go to Viewers and select or create a viewer
- Find the viewer ID in the embed code snippet at the bottom of the page
- Copy the entire iframe code or just the viewer ID
URL Parameters
Customize the viewer appearance using URL parameters:
| Parameter | Description | Example |
|---|---|---|
| bg | Background color (hex without #) | bg=000000 |
| color | Object/model color (hex without #) | color=22d3ee |
| product | Pre-select a specific product by ID | product=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:
- Go to your viewer in the TisFile Dashboard
- In the Settings section, find Allowed Domains
- Add your website domain(s), e.g.,
https://yourshop.com - 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 subdomainhttp://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 Type | Description | Data |
|---|---|---|
| tisfile:ready | Viewer has loaded and is ready | products, initialProductId |
| tisfile:render-complete | STL render completed successfully | success, hasParts |
| tisfile:error | An error occurred | error |
| tisfile:pong | Response 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.