API Reference
Technical documentation for the TimberCloud Embeddable Storefront, including embed script options, the integration script, and URL parameters.
Note: This page covers the technical reference for embedding. If you just want to get the storefront on your site, start with Embed Setup. For brand colors, theme, and layout, see Customization. For the customer-facing shopping experience, see Storefront Features. If you don't already have a website, a hosted white-label website (on your own custom domain) is an alternative to embedding.
Embed Script (embed.js)
The embed script provides the simplest integration method, automatically creating and configuring the iframe.
Usage
<div id="timbercloud-embed"></div>
<script
src="https://embed.timbercloud.com/embed.js"
data-company="your-company-slug"
data-theme="light"
data-width="100%"
data-height="800px"
defer
></script>Attributes
| Attribute | Required | Default | Description |
|---|---|---|---|
data-company | Yes | — | Your TimberCloud company slug |
data-theme | No | light | Passed through to the iframe as an attribute. It does not change the storefront theme — see the note below. |
data-width | No | 100% | Width of the embed (CSS value) |
data-height | No | 800px | Height of the embed (CSS value) |
Important:
data-themeis not consumed by the storefront UI. The script sets it as an attribute on the iframe element, but the storefront's light/dark appearance is controlled by your TimberCloud theme setting (site_theme_mode), and brand colors by your primary/secondary color settings — not by embed code. See Customization for how to set the storefront theme and colors.
What It Does
The embed.js script automatically:
- Creates the iframe inside the
#timbercloud-embedcontainer (the<div>must be the immediate previous sibling of the script). - Sets the return URL to the current page (used so customers land back on your page after actions like password reset).
- Handles password-reset routing when a customer clicks a link from a TimberCloud email (via the
timbercloud_routeandcodeparameters — see URL Parameters). - Listens for
popstateso the embed stays in sync during browser back/forward navigation (helpful for single-page apps). - Auto-resizes the iframe when the storefront sends a
timbercloud:resizemessage. - Cleans URL parameters (
timbercloud_route,code) from your page's address bar after a password reset completes.
Integration Script (timbercloud-integration.js)
For iframe-based integrations, the integration script adds the same automatic routing behavior without using the script-tag embed.
Usage
<iframe
id="timbercloud-embed"
src="https://embed.timbercloud.com/your-company-slug"
width="100%"
height="800"
style="border: none;"
allow="payment"
></iframe>
<script src="https://embed.timbercloud.com/timbercloud-integration.js"></script>What It Does
The integration script automatically:
- Detects TimberCloud iframes on the page. It only acts on iframes whose
srcpoints atembed.timbercloud.com(orlocalhost:3002in local development). Iframes for any other host are ignored. - Appends a return URL to the iframe
srcif one isn't already present, so customers return to your page after actions like password reset. - Sanitizes sensitive query parameters out of that return URL before setting it. Parameters such as
code,token,reset_code,auth,auth_token,access_token,refresh_token,otp, andverification_codeare stripped first, so secrets from your page's URL are never forwarded into the embed. - Handles password-reset routing from email links (forwarding
timbercloud_routeandcodeto the iframe). - Observes DOM changes so dynamically added iframes (or iframes whose
srcis updated) are picked up automatically.
Note: Use either
embed.jsor the iframe +timbercloud-integration.jsapproach — not both. The script-tag embed already includes its own routing logic.
Triggering Re-initialization (SPAs)
For single-page applications, trigger re-initialization after a client-side navigation so newly mounted iframes are processed:
window.dispatchEvent(new Event('timbercloud:reinit'));The script also listens to popstate events automatically.
URL Parameters
The embed accepts the following URL parameters on the storefront URL (https://embed.timbercloud.com/your-company-slug):
timbercloud_return_url
Specifies the URL to return to after actions like password reset. The integration script sets this for you (with sensitive parameters removed); you can also set it manually.
<iframe
src="https://embed.timbercloud.com/your-company-slug?timbercloud_return_url=https://yoursite.com/shop"
...
></iframe>Manual usage:
const currentPageUrl = window.location.href;
const embedUrl = `https://embed.timbercloud.com/your-company-slug?timbercloud_return_url=${encodeURIComponent(currentPageUrl)}`;
document.getElementById('timbercloud-embed').src = embedUrl;timbercloud_route
Navigates to a specific internal route within the embed.
<!-- Open directly to the login page -->
<iframe
src="https://embed.timbercloud.com/your-company-slug?timbercloud_route=/auth/login"
...
></iframe>Available routes:
| Route | Description |
|---|---|
/ | Product catalog (home) |
/product/[id] | Product detail page |
/checkout | Checkout page |
/order-addons | Order add-ons step |
/auth/login | Login page |
/auth/register | Registration page |
/auth/forgot-password | Password-reset request |
/auth/reset-password | Password-reset form (requires code) |
/onboarding | Customer-profile onboarding (logged-in shoppers complete a profile before ordering) |
/orders | Order history |
/orders/[id] | Specific order details |
/orders/confirmation | Order confirmation page |
/account | Account overview |
/account/settings | Account settings |
/account/payment-methods | Saved payment methods |
Note: Routes ending in
[id]are dynamic — substitute a real product or order ID. Most customers reach these screens by navigating inside the storefront;timbercloud_routeis mainly used for deep-linking and email-driven flows.
code
Used for password-reset tokens. Automatically included in password-reset email links and forwarded to the embed alongside timbercloud_route.
Complete Examples
Example 1: Script Embed (Recommended)
<!DOCTYPE html>
<html>
<head>
<title>Shop | Your Site</title>
<link rel="preconnect" href="https://embed.timbercloud.com">
</head>
<body>
<h1>Our Store</h1>
<div id="timbercloud-embed"></div>
<script
src="https://embed.timbercloud.com/embed.js"
data-company="your-company-slug"
data-theme="light"
data-width="100%"
data-height="900px"
defer
></script>
</body>
</html>Example 2: Iframe with Integration Script
<!DOCTYPE html>
<html>
<head>
<title>Shop | Your Site</title>
<link rel="preconnect" href="https://embed.timbercloud.com">
</head>
<body>
<h1>Our Store</h1>
<div style="
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
width: 100vw;
max-width: 100vw;
overflow: hidden;
padding: 0 16px;
">
<iframe
id="timbercloud-embed"
src="https://embed.timbercloud.com/your-company-slug"
width="100%"
height="1280"
style="border: none; border-radius: 8px; display: block;"
title="Product Catalog"
allow="payment"
></iframe>
</div>
<script src="https://embed.timbercloud.com/timbercloud-integration.js"></script>
</body>
</html>Example 3: React Component
import { useEffect, useRef } from 'react';
export function TimberCloudEmbed({
companySlug,
theme = 'light',
height = '800px'
}) {
const containerRef = useRef(null);
useEffect(() => {
const container = containerRef.current;
if (!container) return;
// Create placeholder div
const embedDiv = document.createElement('div');
embedDiv.id = 'timbercloud-embed';
container.appendChild(embedDiv);
// Load embed script
const script = document.createElement('script');
script.src = 'https://embed.timbercloud.com/embed.js';
script.setAttribute('data-company', companySlug);
script.setAttribute('data-theme', theme);
script.setAttribute('data-width', '100%');
script.setAttribute('data-height', height);
script.defer = true;
container.appendChild(script);
return () => {
container.innerHTML = '';
};
}, [companySlug, theme, height]);
return <div ref={containerRef} />;
}
// Usage
<TimberCloudEmbed
companySlug="your-company-slug"
theme="light"
height="900px"
/>Security Considerations
HTTPS Required
All communication occurs over HTTPS. The embed will not function properly on HTTP sites.
Sensitive parameters are stripped
The integration script removes sensitive query parameters (code, token, reset_code, auth, auth_token, access_token, refresh_token, otp, verification_code) from the return URL before passing it to the embed, so secrets in your page's address bar aren't forwarded.
Content Security Policy
If your site uses CSP headers, add these directives:
Content-Security-Policy:
frame-src https://embed.timbercloud.com https://js.stripe.com;
script-src https://embed.timbercloud.com;Troubleshooting
Embed not loading
- Verify the company slug is correct.
- For the Script Embed: ensure
<div id="timbercloud-embed">comes immediately before the script. - Check the browser console for errors.
- Ensure HTTPS is used.
Storefront theme isn't changing
data-themedoes not control the storefront's appearance. Set the storefront theme and brand colors in your TimberCloud settings instead — see Customization.
Password reset not working
- Use the Script Embed, or the iframe + integration script.
- Ensure URL parameters aren't stripped by your server or proxy.
Script Embed: Container not found
- The
<div id="timbercloud-embed">must be the immediate previous sibling of the script. - Ensure the div exists before the script runs (use the
deferattribute).
Integration script isn't acting on my iframe
- The integration script only processes iframes whose
srcpoints atembed.timbercloud.com(orlocalhost:3002in development). Confirm your iframesrcuses theembed.timbercloud.comhost.