Custom data
Most apps need to store data that Shopify's standard data model doesn't include, such as a fabric composition on a product, a warranty record, or a record type that only your app uses.
Custom data stores that information in Shopify, so you don't need to run your own database. The data behaves like the rest of the store's data: you can query it through the GraphQL Admin API, render it in themes, read it from Shopify Functions and extensions, and let merchants edit it in the admin.
Anchor to Metafields or metaobjectsMetafields or metaobjects
Choose based on whether your data describes an existing Shopify resource or stands on its own.
| Metafields | Metaobjects | |
|---|---|---|
| What it is | An extra field on an existing resource | A new record type that you define |
| Use it when | The data describes a product, order, customer, or other Shopify object | The data doesn't belong to an existing Shopify object |
| Examples | Care instructions on a product, a loyalty tier on a customer, a routing rule on an order | A size chart, a store location, an ingredient, a product review |
Most apps use both: a metaobject defines the record, and a metafield attaches it to the products it applies to. To learn how to combine them into one model, see data modeling with metafields and metaobjects.
Anchor to Create definitions firstCreate definitions first
Both metafields and metaobjects start with a definition: a name, a namespace, a type, and validation rules. A defined metafield gets a typed editor in the admin, validation on write, and support for search and filtering. An undefined metafield is stored as a plain string that merchants can't search or validate.
Your app owns its definitions through a reserved namespace, so a merchant's own custom data and another app's data can't collide with yours. Start with managing metafield definitions or metaobject definitions, and check the list of data types for the validation options that each type supports.
Anchor to Where custom data is availableWhere custom data is available
After you store custom data in Shopify, it's available across the platform:
- Shopify admin: Merchants edit the data in a typed editor, if you make the definition visible to them.
- Themes: Storefronts render the data through Liquid and the Storefront API.
- Shopify Functions: Discount and delivery logic reads the data through input queries.
- Checkout and admin extensions: Your extension UI reads the same values as everything else.
- Shopify Analytics: Merchants group and chart on the data, if you mark a definition analytics-queryable.
Anchor to Next stepsNext steps
- Start with metafields if you're extending something Shopify already has.
- Start with metaobjects if you're modeling something new.
- Check the metafield limits and metaobject limits before you design around a large data set.