Should I use an app extension?

scaki
Shopify Partner
2 0 1

Hello, we are trying to make a shopify application for our currently live project. Our application generates an embed code (a simple js file) and we expect our users to add it to their sites. For this, I am currently using the script tag api. Do I need to migrate to app extension? In which cases should I use an application extension?

Reply 1 (1)

sherpabot
Shopify Partner
16 0 2

Yea, based on the documentation suggestions creating an extension appears to be the best solution to "cleanly"/safely inject tags based on 2.0 themes. 

be sure to read up on the app-building documentation here: https://shopify.dev/docs/apps/tools/cli/structure
https://shopify.dev/docs/apps/online-store/theme-app-extensions

https://shopify.dev/docs/apps/online-store/theme-app-extensions/extensions-framework#app-embed-block...



Inside the theme extensions block folder (within the application project) you will create something like this:

{% schema %}
{
  "name": "Your Name",
  "target": "body", // THIS IS IMPORTANT
  "stylesheet": "file-name.css",
  "javascript": "file-name.js",
  "settings": []
}
{% endschema %}