App Data Metafield usage in Checkout UI Extensions

I’m trying to access a Metafield inside a Checkout UI extension, to conditionally display features based on the merchant’s plan with the app.

After reading the docs, it looks like the only way is to create a new Metafield definition with the $app namespace, and perhaps assign ownerType to SHOP. Then, set one Metafield under that definition to be able to read it inside the UI extension.

This works, but if it were possible to use App data metafields instead, it would avoid adding yet more definitions under the SHOP owner, and nicely tidying things up if the merchant uninstalls the app. Without this ability, apps can leave dozens of unused definitions behind, after an uninstall (checked one dev account and saw at least 10 of those).

There are other comments about this, from earlier in the year. Are there any upcoming plans to make App data metafields accessible in the Checkout UI? It would be awesome to have that before we add this extension. It’s cumbersome to update later on after it gets going live for merchants.

Looks like app metafields are supported now. https://shopify.dev/docs/api/checkout-ui-extensions/latest/configuration#:~:text=App%20owned%20metafields-,App%20owned%20metafields,-App%20owned%20metafields

You shouldn’t need to create a definition for your metafield if you are only using them inside your app/checkout

Thanks, Jordan.

I tested now and see that I can create metafields without adding a definition first. That helps eliminate one step.

However, those are still “App owned metafields”. These are different from “App data metafields”.

The former must be associated with a resource like SHOP or PRODUCT etc, even though they’re controlled exclusively by the app. The problem is when the app is uninstalled, it leaves those metafields behind inside the merchant’s Admin Settings.

The latter is associated with the app installation itself (not a SHOP, not a PRODUCT etc), and doesn’t even show in the Admin Settings. I assume these also get deleted when the app is removed, so it’s a neater solution all around.

We can already use “App data metafields” for Theme Extensions, and I was hoping to be able to use them in Checkout/Customer UI extensions, too.

Hey, ahhh my apologies miss understood the terminology (naming things is hard) :joy:

Yeah that makes sense, lots of apps are doing the shop metafield thing but it would be cleaner if these were removed on uninstall. Perhaps this will come with managed metafields.

In terms of app owned metafields on an app installation being used in extensions, one for the Shopify team then.

@Liam-Shopify, do you know if the team is planning on enabling access to “App data metafields” in Checkout/Customer UI extensions anytime soon?

We’re about to launch an extension in an existing app and I’d like to avoid creating a bunch of Shop Metafields for all installed merchants to store some data the app needs.

It would be so much cleaner to use the App data metafield that already works in Theme extensions, and that don’t linger around after the app is uninstalled.

Alan is sending this as a feature request to Shopify, so closing it now.