Shopify theme app extensions: how an app should plug in to your theme

Topic
Development
Published
Reading time
8 min read
Written by
Binaery

A Shopify theme app extension is the clean way for an app to put something on your storefront. The app's piece arrives as a block you place in the theme editor, the app never edits your theme's code, and taking it out again doesn't leave code in your theme. The older way, where an app wrote its own code into your theme files, is why so many stores carry leftovers from apps they removed years ago.

This is for the developer on your team, or the founder choosing between two apps. By the end you'll know the two kinds of block an app can add, what your theme needs to accept them, and how to tell which way an app plugs in before you install it.

The short version

  • An app built with a theme app extension doesn't edit theme code. Its parts show up in the theme editor for you to place.
  • An app block is content inside a page, like a row of stars or a reviews list. You add it to a section and can move it.
  • An app embed is something floating or invisible, like a chat bubble or a tracking pixel. You switch it on under Theme settings, then App embeds.
  • Both are off after install. Nothing appears until you add or activate it.
  • For app blocks, the theme has to allow them: JSON templates, and sections that accept blocks from apps.
  • An app that still asks you to paste code into the theme is one to ask questions about.

Here's the line in a theme that lets apps in. It's a section's settings, with one kind of block allowed:

{% schema %}
{
  "name": "Product",
  "blocks": [{ "type": "@app" }]
}
{% endschema %}

The part that matters is @app. It tells Shopify that blocks from installed apps may be added to this section. With it, your team can drop a reviews app's stars into the product section from the theme editor. Without it, they can't, and somebody ends up pasting code.

The old way, and why it left a mess

For years an app that wanted to show something on a store did it by writing into the theme: a snippet file here, a line in the layout there, a script tag in the head. It worked, and it had two problems.

The first is what happens when you remove the app. Shopify's help center says that uninstalling an app doesn't automatically remove its code from your theme. The code keeps loading for every visitor.

The second is updates. Code an app wrote into your theme is a code edit like any other, and our article on updating a theme covers what happens to those.

Shopify's answer is the theme app extension. Its docs put the benefit in one line: apps built this way don't edit theme code, which lowers the risk of breaking the theme. The app's files stay with the app, hosted by Shopify, and the theme only holds a note saying where each block goes.

App blocks: content inside the page

An app block is for anything that belongs in the flow of a page. Shopify's configuration guide gives the cases: apps that should follow the product on the page, such as reviews and star ratings, things your team may want to reposition, and things that span the full width.

Here's what one looks like from the app developer's side, cut down from Shopify's example:

<p>{{ block.settings.message }}</p>
{% schema %}
  {
    "name": "Hello World",
    "target": "content",
    "settings": [
      { "label": "Message", "id": "message",
        "type": "text", "default": "Hello" }
    ]
  }
{% endschema %}

It's the same shape as a section in a theme: some markup, and a list of settings the theme editor shows. The target line says it's content for a page. The difference is where the file lives. It's in the app, not in your theme.

What that means for your team:

  • After install, the block isn't on the store. Somebody adds it from the Apps part of the theme editor.
  • It can be moved, removed and reordered like any other block.
  • Its settings are edited in the theme editor, next to the theme's own.

Here's a reviews section we designed for a protein brand, on a phone: five stars, a headline with the number of customers, two videos and one button to read the reviews. A section like this is where a reviews app's block would sit. The design decides the room it gets. The app fills it.

Customer reviews on a phone, as designed Protein brand Customer reviews on a phone, as designed

That room matters for another reason. An app's content often arrives a moment after the page, and if no space was left, the page jumps. Our article on Core Web Vitals shows the two lines of CSS that reserve it.

App embeds: floating things and invisible things

An app embed is for whatever doesn't sit inside the page: a chat bubble, a badge laid over product pictures, analytics, a tracking pixel, extra tags for search engines. Shopify adds these just before the end of the page's head or body.

  • They're off after install. You activate them in the theme editor, under Theme settings, then App embeds.
  • They work on older themes as well as current ones, because they don't depend on sections.
  • They can be limited to the pages that need them, which Shopify notes wasn't possible with the older way of adding scripts.

That list under App embeds is worth opening on your own store. It's the nearest thing to an honest inventory of what your apps add to every page, each with its own switch.

What your theme needs

App embeds work almost anywhere. App blocks need two things from the theme, according to Shopify:

  • JSON templates. This is the architecture Shopify's current themes use.
  • Sections that accept app blocks, which is the @app line at the top of this article.

Shopify's own Dawn theme has both in its main product section, and Shopify points to it as the example to follow. A custom theme has them where its developer put them. We'd make sure the product section and the main page sections accept app blocks, because that's where a team will want to add things later. If your theme's product section doesn't, adding that line is a small job.

How to tell which way an app plugs in

  1. Read the install steps before installing. "Add the block in the theme editor" or "enable the app embed" is the new way. "Paste this code into theme.liquid" is the old way.
  2. Look for the Built for Shopify badge. Shopify's help center says apps with it use Shopify's latest technology standards, and can't lower your storefront's speed by more than 10 performance points.
  3. After installing, look in the theme editor. The app's blocks appear under Apps when you add a block, and its embeds under Theme settings.
  4. Ask the developer. "Does your app use a theme app extension, or does it edit theme files?" is a fair question, and a good app answers it quickly.

Our own app, Atomato, puts its bell on a store this way. Merchants place it without touching theme code.

A worked example: removing an app properly

Say you're replacing a reviews app you installed four years ago.

  1. In the theme editor, find the old app's blocks and remove them. Open App embeds and switch its embed off.
  2. Uninstall the app.
  3. On a copy of the theme, search the code for the app's name and its script address. Shopify's guide to auditing third party scripts says to check the layout file, the snippets folder and any render tags that point at the app's snippets.
  4. Remove what you find, and preview the copy on a phone.
  5. Install the new app, add its block where the old stars were, and check that the page doesn't jump when it loads.
  6. View the page's source and search for the old app's domain. It should be gone.

With an old app, step three is where the time goes. With an app built the new way, there's nothing to find.

What a theme app extension won't fix

  • A heavy app. Plugging in cleanly doesn't make an app's script small. It still loads, and too many still slow the page.
  • Design. An app's block looks the way the app's developer made it. Matching it to your store may still take some CSS.
  • Old leftovers. Code from apps installed the old way stays until somebody takes it out.
  • Whether you need the app. Our article on apps or custom code is about that question.

Before you install the next app

  1. Read its install steps. Blocks and embeds, or pasted code?
  2. Check for the Built for Shopify badge.
  3. Check that the section you want it in accepts app blocks.
  4. Install it on a copy of the theme first, and place the block there.
  5. Watch the page load on a phone. Does anything move?
  6. Open App embeds and switch off anything you don't use.
  7. Write down what you installed and where its blocks are, for whoever removes it one day.

Common questions

What is a Shopify theme app extension?

A theme app extension is the way a Shopify app adds content to a storefront without editing the theme's code. It contains app blocks, which merchants place inside sections in the theme editor, and app embed blocks, which add floating or invisible elements such as chat bubbles and tracking. The app's files stay with the app.

What is the difference between an app block and an app embed?

An app block is content inside a page, such as star ratings or a reviews list. It's added to a section in the theme editor and can be moved. An app embed is added before the end of the page's head or body, for floating elements, analytics and pixels, and it's switched on under Theme settings, then App embeds.

Does uninstalling a Shopify app remove its code?

Not always. Shopify's help center says uninstalling an app doesn't automatically remove its code from your theme. Apps built with theme app extensions don't edit theme code, so they leave nothing behind. For older apps, search the theme files for the app's name and remove what's left.

Why can't I add an app block to my Shopify theme?

App blocks need a theme with JSON templates and sections that accept blocks of the type @app. If a section doesn't allow app blocks, the app's block won't be offered there in the theme editor. A developer can add app block support to a section.

Next step

Open the theme editor, go to Theme settings and then App embeds, and read the list. Switch off anything from an app you no longer use, and note anything you don't recognize. It tells you more about what loads on your store than the Apps page does. If the list is long and the theme is full of older leftovers, a clean up is the kind of job our developers do. Tell us about your store and one of us will write back within 48 hours.

Keep reading.

Rather have us do it?

Everything in this article is something we do for a living. Tell us about the store and what you're trying to move.

Get a quote