Getting started with theme app extensions
Theme app extensions allow merchants to easily add dynamic elements to their themes without having to interact with Liquid templates or code. You can start building theme app extensions with Shopify CLI.
What you'll learnAnchor link to section titled "What you'll learn"
After you've finished this tutorial, you'll have accomplished the following tasks:
- Created a theme app extension
- Previewed the theme app extension
- Tested the theme app extension
- Added onboarding instructions in your app
- Deployed and released the theme app extension
RequirementsAnchor link to section titled "Requirements"
- You've created a Partner account.
- You've created a development store that uses generated test data.
- You've created an app that uses Shopify CLI 3.0 or higher.
- You've installed an Online Store 2.0 theme, such as Dawn, that uses JSON templates and supports app blocks.
- You've installed the additional project dependencies (Ruby and Bundler).
- You understand the theme app extensions framework.
Step 1: Create a new extensionAnchor link to section titled "Step 1: Create a new extension"
You'll use Shopify CLI to generate a new extension.
Navigate to the directory of the app that you want to add your extension to.
Run the following command to start creating the extension:
Theme app extensionas the extension type.
Provide a name for your extension.
You should now have a new extension directory that includes a working example of a theme app extension that displays product ratings.
The generated extension requires a metafield definition with the following properties:
- Area: Products
- Namespace: demo
- Key: avg_rating
- Type: Integer
After you create the metafield definition, set a value for the metafield on at least one product in your development store.
Step 2: Preview your theme app extensionAnchor link to section titled "Step 2: Preview your theme app extension"
You can preview your extension by running the
dev command, which starts a local development server that supports hot reloading. This preview is available only in Google Chrome.
Navigate to your app directory.
Run one of the following commands:
You can specify which theme you want to use to host your theme app extension using the
--theme <ID or name>flag. If you don't specify a theme, then the command will upload Dawn, Shopify's example theme, to the development store.
When you run the
devcommand, the CLI builds your app and bundles your app extensions. It also walks you through multiple configuration steps. If you've already run
deployfor this app, then some of these steps are skipped.
To learn about the processes that are executed when you run
dev, refer to the Shopify CLI command reference.
Follow the instructions in the CLI output to preview the theme app extension. This includes the following steps:
- Opening the host theme in the theme editor
- Adding your app block to the theme
- Saving the theme
Click the URL that's printed at the bottom of the CLI output to preview your extension.
Step 3: Test your changesAnchor link to section titled "Step 3: Test your changes"
Verify that your app looks and behaves correctly by testing your changes on a theme in your development store.
In your development store, go to an Online Store 2.0 theme and navigate to the theme editor.
Follow the procedures for:
Verify the app behaves as expected. For example, verify the following:
- App embed blocks for floating components are positioned properly without obscuring page content.
- You can use the theme editor to activate and deactivate app embed blocks and configure their settings.
- You can use the theme editor to add, remove, and reposition app blocks and configure their settings.
- App documentation, such as app onboarding instructions, is clear, accurate, and complete. To learn more about writing effective help documentation, refer to Help documentation in Shopify Polaris.
Step 4: Include onboarding instructions in your appAnchor link to section titled "Step 4: Include onboarding instructions in your app"
Provide instructions for what merchants need to do after installing your app. For more information, refer to the UX guidelines.
Step 5: Deploy and release the extensionAnchor link to section titled "Step 5: Deploy and release the extension"
When you're ready to release your changes to users, you can create and release an app version. An app version is a snapshot of all of your app extensions.
For more information about extension deployment and versioning, refer to Deploy app extensions.
- Navigate to your app directory.
Run one of the following commands.
Optionally, you can provide a name or message for the version using the
Releasing an app version replaces the current active version that's served to stores that have your app installed. It might take several minutes for app users to be upgraded to the new version.