Skip to content

测试版

这些 App Bridge 组件是新加入的,测试期间,API 可能会在 minor 版本中变更。它们的行为由本地 E2E 测试套件在真实的 Shopify admin 中检查。如有问题,请提交 issue。

身份验证和数据 ​

Shopify 归入“身份验证和数据”的 API,以及只有它们使用的类型。本页:AppApi、AppBridgeConfig、EnvironmentApi、IdTokenApi、Scopes、UserApi。

AppApi ​

interface

extensions(): Promise<ExtensionInfo[]>

The list of extensions from the current app.

ExtensionInfo ​

interface

类型参数: Type extends ExtensionType = ExtensionType

handle: string

The unique identifier for the extension.

activations: Type extends "ui_extension" ? UiExtensionActivation[] : Type extends "theme_app_extension" ? ThemeExtensionActivation[] : never

List of activation records for the extension. The shape depends on the extension type:

  • UI extensions have activations with only target
  • Theme app extensions have nested activations representing blocks/embeds

type: Type

The type of the extension.

用于: AppApi

ExtensionType ​

type
ts
type ExtensionType = "ui_extension" | "theme_app_extension";

用于: ExtensionInfo

ThemeExtensionActivation ​

interface

target: ThemeAppBlockTarget | ThemeAppEmbedTarget

The target location type for this block/embed.

  • section for blocks
  • head, body, or compliance_head for embeds

handle: string

The filename of the block/embed within the theme app extension (without extension). This is configured by the developer when creating the block file.

name: string

The developer-configured display name of this block/embed, defined in the block's schema.

参见: https://shopify.dev/docs/apps/build/online-store/theme-app-extensions/configuration#schema

status: ActivationStatus

The availability status of this block/embed.

activations: ThemeAppBlockActivation[]

List of theme-specific activations for this block/embed. Contains where the block is actually placed within themes.

用于: ExtensionInfo

UiExtensionActivation ​

interface

target: string

The target identifier for the extension activation. For example, purchase.thank-you.block.render.

用于: ExtensionInfo

ActivationStatus ​

type
ts
type ActivationStatus = "active" | "available" | "unavailable";

ThemeAppBlockActivation ​

interface

target: string

The target identifier for the block/embed placement within the theme. For example, template--product.alternate/main/my_app_product_rating_GPzUYy.

themeId: string

The theme ID where this block/embed is activated. Format: gid://shopify/OnlineStoreTheme/{id}

ThemeAppBlockTarget ​

type
ts
type ThemeAppBlockTarget = "section";

ThemeAppEmbedTarget ​

type
ts
type ThemeAppEmbedTarget = "head" | "body" | "compliance_head";

AppBridgeConfig ​

interface

apiKey: string

The client ID (also known as the API key) for your application, found in the Shopify Partner Dashboard under your app's settings.

You must provide this value using a <meta name="shopify-api-key"> tag.

appOrigins?: string[]

An allowlist of origins that your app can send authenticated fetch requests to.

Set this property if your app needs to make authenticated requests to a domain other than your app's origin. Requests to your app's own domain (and its subdomains) are automatically allowed.

Each value must be an origin in the format scheme://hostname or scheme://hostname:port (for example, 'https://example.com' or 'https://example.com:8443').

debug?: DebugOptions

Configuration for enabling Web Vitals performance logging.

Use this property during development for identifying performance issues.

disabledFeatures?: string[]

An array of App Bridge feature names to disable in your app.

Supported values:

  • 'fetch' — Disables App Bridge's automatic fetch interceptor, which adds authentication headers to requests to the Shopify Admin API.
  • 'auto-redirect' — Disables automatic redirection when the app is loaded outside of the Shopify Admin.

experimentalFeatures?: string[]

The experimental features to enable in your app.

This allows app developers to opt-in to experiement features.

host?: string

The base64-encoded host of the shop that's embedding your app. When decoded, the value has the format admin.shopify.com/store/{shop-name}.

This property is automatically set by the host environment.

locale?: string

The locale of the admin user viewing your app, as an IETF BCP 47 language tag (for example, 'en-US', 'fr-FR', 'ja-JP').

This reflects the language the merchant has chosen for the Shopify admin, not the shop's customer-facing locale.

This property is automatically set by the host environment.

默认值: 'en-US'

shop?: string

The permanent .myshopify.com domain of the shop that's embedding your app (for example, 'my-store.myshopify.com'). This is always the Shopify-assigned domain, not a custom domain.

This property is automatically set by the host environment.

DebugOptions ​

interface

webVitals?: boolean

Enables or disables the logging of web performance metrics (Web Vitals) in the browser's console.

When set to true, the app will log Core Web Vitals (such as LCP, INP, and CLS) and other relevant performance metrics to help developers understand the real-world performance of their app. This can be useful for debugging performance issues during development or in a staging environment.

This field is optional and defaults to false, meaning that web vitals logging is disabled by default to avoid performance overhead and unnecessary console output in production environments.

默认值: false

用于: AppBridgeConfig

EnvironmentApi ​

interface

继承: Required<_EnvironmentApi>

_EnvironmentApi ​

interface

mobile?: boolean

Whether the app is running inside the Shopify Mobile app.

embedded?: boolean

Whether the app is embedded in the Shopify admin.

pos?: boolean

Whether the app is running inside the Shopify POS app.

intent?: boolean

Whether the app is running as an intent.

用于: EnvironmentApi

IdTokenApi ​

function
ts
type IdTokenApi = () => Promise<string>;

Scopes ​

interface

query: () => Promise<ScopesDetail>

Returns the current access scopes for this app on this shop, including which are granted, required, and optional.

request: (scopes: Scope[]) => Promise<ScopesRequestResponse>

Opens a permission grant modal asking the merchant to grant the specified scopes.

The scopes must be access scope handles (for example, 'read_products' or 'write_orders') that are declared as optional in your app configuration.

See the permission grant modal documentation for more details.

revoke: (scopes: Scope[]) => Promise<ScopesRevokeResponse>

Revokes the specified optional scopes from this app on this shop.

The scopes must be access scope handles (for example, 'read_products' or 'write_orders') that are currently granted and declared as optional. Required scopes cannot be revoked.

Scope ​

type
ts
type Scope = string;

用于: Scopes, ScopesDetail

ScopesDetail ​

interface

granted: Scope[]

The scopes currently granted to this app on this shop. This includes both required and optional scopes.

required: Scope[]

The scopes declared as required in your app configuration. These are always granted at install time and cannot be revoked by the app.

optional: Scope[]

The scopes declared as optional in your app configuration. These may or may not be currently granted — check granted to see which are active.

ScopesRequestResponse ​

interface

result: UserResult

The merchant's response: 'granted-all' if they accepted all requested scopes, or 'declined-all' if they declined.

detail: ScopesDetail

The updated scopes for this app on this shop after the merchant's response.

用于: Scopes

ScopesRevokeResponse ​

interface

detail: ScopesDetail

The updated scopes for this app on this shop after the revocation.

用于: Scopes

UserResult ​

type
ts
type UserResult = "granted-all" | "declined-all";

UserApi ​

function
ts
type UserApi = () => Promise<User>;

引用: User用于: useAppBridge(), ShopifyGlobal

User ​

interface

用于: UserApi

AdminUser ​

interface

accountAccess?: string

The account access level of the logged-in user.

locale?: string

Host regional format. Copied onto shopify.config.locale.

POSUser ​

interface

id?: number

The staff member's numeric ID.

firstName?: string

The user's first name.

lastName?: string

The user's last name.

email?: string

The user's email address.

accountAccess?: string

The account access level of the logged-in user.

accountType?: string

The user's account type.

用于: User

PrivilegedAdminUser ​

interface

继承: AdminUser

id?: number

The staff member's numeric ID.

name?: string

The staff member's full name.

email?: string

The staff member's email address.

用于: User

基于 MIT 许可证发布。Vue 标志由 Evan You 设计,采用 CC BY-NC-SA 4.0 许可。