--- title: Using metafields for custom data in checkout description: Learn how to configure metafields for your checkout UI extension. source_url: html: 'https://shopify.dev/docs/apps/build/checkout/metafields' md: 'https://shopify.dev/docs/apps/build/checkout/metafields.md' --- # Using metafields for custom data in checkout [Metafields](https://shopify.dev/docs/apps/custom-data/metafields) are key-value pairs that you can use to store custom data on a Shopify resource. You can use metafields to store data that is specific to your checkout UI extension, such as the extension's configuration or the buyer's consent. To access metafields in your checkout UI extension, use the [Metafields API](https://shopify.dev/docs/api/checkout-ui-extensions/latest/target-apis/platform-apis/metafields-api). For a full tutorial on using metafields read and write custom data in your checkout UI extension, see [Display custom data at checkout](https://shopify.dev/docs/apps/build/checkout/display-custom-data). *** ## Configuring metafields To use metafields in your checkout UI extension, you need to configure them in your extension's [`.toml` configuration file](https://shopify.dev/docs/apps/build/app-extensions/configure-app-extensions) file. To define a metafield that's available to your extension wherever it's rendered in the checkout, use the`extensions.metafields` property. To define a metafield that your extension can access only from a specific extension target, use the `extensions.targeting.metafields` property. The following example snippet shows two metafields defined using these properties: ## shopify.extension.toml snippet ```toml # Define a metafield your extension can access from anywhere in checkout [[extensions.metafields]] namespace = "my-namespace" key = "my-key-1" [[extensions.targeting]] target = "purchase.checkout.actions.render-before" module = "./Actions.jsx" # Define a metafield your extension can access only from the above target [[extensions.targeting.metafields]] namespace = "my-namespace" key = "my-target-key" ``` ### App owned metafields When your app needs to control the data and visibility of the metafield, you can use [app owned metafields](https://shopify.dev/docs/apps/build/metafields#app-owned-metafields). Using an app-owned metafield prevents other apps or merchants from accessing or modifying the data stored in the metafield. Your extension can only access app-owned metafields that belong to its parent app. The following example snippet shows a definition for an app-owned metafield: ## shopify.extension.toml snippet ```toml # app owned metafield [[extensions.metafields]] namespace = "$app:my-app-owned-namespace" key = "my-key-3" ``` *** ## Supported resource metafield types The following resource metafield types are supported: | Resource | Description | | - | - | | `cart` | The cart associated with the current checkout. | | `company` | The company for B2B checkouts. | | `companyLocation` | The company's location for B2B checkouts. | | `customer` | The customer account that is interacting with the current checkout. | | `product` | The products that the buyer intends to purchase. | | `shop` | The shop that is associated with the current checkout. | | `shopUser` | The [Shop app](https://shop.app/) user that is associated with the current checkout if there is one. | | `variant` | The product variants that the customer intends to purchase. | ***