Non-Shopify headless storefront guide
Purpose
This guide explains how a non-Shopify headless storefront should prepare a signed config payload, expose it to the Tern storefront module, and mount <tern-trade-in>.
This path supports merchant-signed headless bootstrap without Shopify customer authentication.
If the storefront belongs to a Shopify shop and you need logged-in customer support, use Shopify Headless Storefront Integration Guide.
If you cannot use headless authentication at all, use Standalone Storefront Integration Guide.
Recommendation First
This guide is for non-Shopify headless storefronts that can still generate merchant-signed bootstrap payloads on their backend.
It is stronger than the standalone no-proof flow because the request is signed server-side, but it does not include Shopify customer authentication.
Summary
The implementation has three steps:
Get the merchant shared secret from Tern.
Use that shared secret on your backend to sign the bootstrap request payload.
Expose
window.ternStorefrontConfigbefore mounting<tern-trade-in>.
What Is Different From Shopify Headless
This guide uses the same merchant-signed proof type as the Shopify guide, but with these restrictions:
No logged-in Shopify customer context.
No
proof.customerobject.The signature must always use an empty
emailvalue.The signature must always use
id=0.
Shared Secret
Before implementing the bootstrap call, obtain the merchant shared secret from the Tern admin interface for the relevant shop.
Implementation guidance:
Generate or copy the shared secret from the Tern admin interface.
Store the shared secret on your backend.
Do not expose the shared secret in browser code.
Use the shared secret only on the server when generating the HMAC signature.
Config Format
Expose window.ternStorefrontConfig with these fields:
shopDomainlocaleproof
Browser config uses shopDomain. The storefront runtime converts that to the API field shop_domain before calling the bootstrap endpoint.
Example:
How To Sign The Request
When using merchant_signed, your backend must sign the full canonical string shown below with HMAC-SHA256 using the merchant shared secret.
Only these four values are part of the signature:
emailshop_domainidtimestamp
Sign this exact canonical string:
For non-Shopify headless bootstrap:
emailmust be an empty string.shop_domainmust be the configured shop domain for the storefront.idmust be0.timestampmust be a Unix timestamp in seconds.The signature must be lowercase hex.
Generate the signature on your backend, never in browser code.
Node.js Example
Do not include proof.customer in this flow.
Bootstrap Response
After the storefront module initializes, it obtains a bootstrap response that includes:
tokenlocalega_measurement_id
shopify_customer is not expected in this flow.
Example response:
The returned token is a Tern storefront session token. It is not proof of Shopify customer identity.
Browser Runtime And Mount
Use the same runtime loading and mount pattern as Shopify Headless Storefront Integration Guide.
The only difference is the config payload. Use this body snippet instead:
For shared prerequisites, see What The JavaScript Example Assumes.
Implementation Checklist
Obtain the merchant shared secret from the Tern admin interface.
Store the shared secret on your backend.
Build the canonical payload with empty
emailandid=0.Sign the payload on your backend.
Expose
shopDomain,locale, andproofinwindow.ternStorefrontConfigbefore mounting the storefront.Load the storefront browser bundle.
Mount
<tern-trade-in>afterwindow.ternStorefrontConfigis defined.Let the storefront module initialize the storefront session from that config.
Use the returned
tokenas the storefront session token.If you later need authenticated customer context, move to Shopify Headless Storefront Integration Guide.
Last updated