TanqoryDocs

App blocks

Put your app's UI inside a store's pages as a block the merchant places in the theme editor, with merchant settings, files Tanqory serves from the store's own address, and the tqAppBlocks mount API.

An app block is your UI inside a section of a store's page. The merchant adds it in the theme editor like any block of the theme, fills in your settings and moves it where it fits. On the page, Tanqory writes an empty placeholder with the settings, loads your script and stylesheet from the store's own address, and your script fills the placeholder in the shopper's browser.

Use a block for anything that belongs in the page. For a floating button or a script that runs on every page, use an app embed; Theme app extensions compares the two and lists the review rules.

How it reaches the page

An app block on a store's page
  1. Merchant (theme editor) → Tanqory Adds your block to a section and fills in its settings
  2. Tanqory → Shopper's browser The page, with the placeholder, your stylesheet and your script from the store's own address
  3. Shopper's browser Your script registers, then mounts into each placeholder with its settings

Your files are uploaded with the app version and stored under their SHA-256, so the file a reviewer read is the file shoppers get. They are served from the store's own address, which is what the store's security policy allows, and cached for good: a change is a new file with a new name in a new version.

1. Write the script

Register each block once, when your script first runs:

Node.js
// blocks/booking.js
window.tqAppBlocks.register('booking', {
  mount(root, settings, info) {
    // root: an empty element of yours inside the block's placeholder
    // settings: the merchant's values for this block, as an object
    // info: { type: 'app:<app>/booking', id, element } (element is the placeholder)
    const box = document.createElement('div');
    box.className = 'booking';
    const title = document.createElement('h3');
    title.textContent = settings.heading ?? 'Check availability';
    box.append(title);
    root.append(box);
  },
  unmount(root) {
    // optional: stop timers and listeners; root is removed after this
  },
});
PartWhat it is
register(name, block)name is the block's handle, or its full type app:<app>/<handle>. Returns true, or false when that type is already registered.
mount(root, settings, info)Runs once for each placeholder of this block on the page, and again for each one the editor adds or redraws. root is a new, empty element appended inside the placeholder: render into it and nowhere else.
unmount(root)Optional. Runs when a placeholder leaves the page, for example when the merchant changes a setting in the editor (the block is drawn again and mounted again with the new values).

Keep these in mind:

  • Call register with the handle while your script first runs. The short name is matched to your app through the script tag that is running; from a callback or a timer, pass the full type app:<app>/<handle> instead.
  • One placeholder, one mount. A merchant may add the block twice on a page; each gets its own root and settings.
  • A mount that throws is logged in the console and leaves only that block empty; the rest of the page carries on.
  • Read the page, not the theme. The page address (location.pathname, such as /products/<handle>) tells you which product or collection the page is about. Do not look up the theme's elements: the merchant decides where your block sits.
  • Talk to your server through the app proxy on the store's own address (/apps/<subpath>/...). The store's security policy refuses calls to other addresses, and iframes.
  • Style only your own elements. Use a class of your own on everything you render and inherit the theme's fonts and colours. Your stylesheet is loaded in the page head.

2. Declare the block

A block has a handle, a name, the script, an optional stylesheet and the settings the merchant fills in. Declare it in tanqory.extensions.json and push it with the tanqory-partner command line, which uploads both files first:

JSON
{
  "app": "<your app id>",
  "themeAppBlocks": [
    {
      "handle": "booking",
      "name": "Booking form",
      "description": "Dates and free rooms, under a room's details.",
      "icon": "https://cdn.example.com/booking-icon.png",
      "script": "blocks/booking.js",
      "style": "blocks/booking.css",
      "settings": [
        { "key": "heading", "type": "text", "label": "Heading", "default": "Check availability" },
        { "key": "maxNights", "type": "range", "label": "Longest stay", "min": 1, "max": 30, "step": 1, "default": 14 },
        { "key": "layout", "type": "select", "label": "Layout", "options": [{ "value": "stacked", "label": "Stacked" }, { "value": "inline", "label": "In one row" }], "default": "stacked" }
      ],
      "targets": ["section"],
      "requires": ["product"]
    }
  ]
}
Shell
tanqory-partner app extensions check
tanqory-partner app extensions push
FieldRules
handle1 to 64 lower-case letters, digits or hyphens, starting with a letter or digit; unique in the app. Themes keep the block by it.
nameWhat the merchant sees in Add block, at most 100 characters.
descriptionOne line for the block picker, at most 500 characters.
iconAn https image for the block picker.
scriptRequired. JavaScript, UTF-8, at most 64 KiB.
styleCSS, UTF-8, at most 100 KiB; no @import, expression( or javascript:.
settingsAt most 25. See below.
targetsWhere the merchant may add it: section (directly in a section), block (inside another block), or both (the default). A theme save refuses it anywhere else.
requiresThe kinds of page it is for, such as product. Add block offers it only on those pages, and a theme save refuses it on any other.

The partner dashboard's Extensions, Add app block does all of this too, settings, icon, where it goes and its pages included, and Edit on a row changes a block you have.

Settings

Each setting is { key, type, label } with optional info (help under the field, at most 300 characters), default, and for some types options, min, max, step.

typeThe merchant getsExtra fields
text, textarea, richtextTextdefault at most 1000 characters
urlAn address
colorA colour
booleanA switch
selectA listoptions: 1 to 50 { value, label }
rangeA slidermin and max (required), step
numberA numbermin, max, step
imageAn image from the store's files
product, collectionA product or collection of the store

key starts with a letter and has up to 64 letters, digits or _. When the merchant adds the block, each setting starts at its default. The theme editor checks the merchant's values against your settings when the theme is saved.

Through the API

The command line calls the Partner GraphQL API. For each file, partnerAppBlockAssetUploadCreate(input: { appId, kind: SCRIPT | STYLE, name, sha256, fileSize }) answers a grant that lasts 5 minutes: send the file's bytes as the body of POST <url> with Authorization: Bearer <token>. The answer's path (<name>-<first 8 hex of the SHA-256>.js or .css), sha256 and bytes go into the block's script or style in partnerAppUpdate(id, input: { themeAppBlocks: [...] }).

RefusalWhy
file_too_largeMore than 64 KiB (script) or 100 KiB (stylesheet)
size_mismatch, hash_mismatchThe bytes sent are not the ones the grant names
invalid_fileNot UTF-8, a NUL byte, or a refused CSS construct
malware_detectedThe malware scan found something
invalid_grantThe grant expired (5 minutes) or is for another file
invalid_parameterIn partnerAppUpdate: the field path says which, such as themeAppBlocks.0.script.path

Uploads are limited to 120 grants an hour per app.

3. Try it on a development store

  1. Install the app on a development store.
  2. In the store dashboard, open Online Store, Themes, and Customize on a theme.
  3. Open a page with a section that accepts app blocks (in Tanqory's Nova theme: product details, rich text, group and stack), select Add block, then the Apps tab, and pick your block. The editor's preview runs your script, so you see the block and each setting change.
  4. Save, publish or preview the theme, and open the page.

A section shows the Apps tab only when the theme lets it take app blocks. Theme developers: list @app among the blocks a section or block accepts; it is not allowed on layout components such as the header and footer, or in presets.

Limits

Blocks per app30
Settings per block25
Script64 KiB
Stylesheet100 KiB
App blocks per store, all apps200

When the app is uninstalled

Your blocks leave every theme of the store, recorded in each theme's history as removed because the app was uninstalled, so the merchant can restore them after reinstalling. Until that change reaches a theme, the editor shows your block as not available.

Built from commit c0b3fb3fdef7 · API version 2026-10