> Deprecated: > The [Embedded App SDK (EASDK)](/docs/api/embedded-app-sdk) and the [POS App SDK](/docs/api/pos-app-sdk) are deprecated. After March 1st, 2022, apps that are using either of these SDKs won't be listed on the Shopify App Store. Use [Shopify App Bridge](/docs/api/app-bridge) instead. ## ShopifyApp.init(config) > Note: > The equivalent method in Shopify App Bridge is [`createApp`](/docs/api/app-bridge/previous-versions/methods#createapp-config). Should be called immediately after the script file has loaded, as early as possible on the page (not in a `jQuery.ready()` or something). It will initialize data values, add `postMessage` listeners, check that the app is embedded in an iframe, and setup our initializers. The config hash can contain the following keys:
Key | Type | Description |
---|---|---|
apiKey |
String | ff9b1d04414785029e066f8fd0465d00 or similar. The client credentials provided to you for your application in the Partner Dashboard. |
shopOrigin |
String | The origin of the Shopify shop. This will come out of the session values returned from the Shopify API and should be set dynamically for each different store. It'll be something like "https://example.myshopify.com" and should always include the protocol. |
forceRedirect |
Boolean | Defaults to true . Can be used to disable redirection into the admin for debugging or testing purposes. |
debug |
boolean | Defaults to false . Will activate some console.log logging output. |
Key | Type | Description |
---|---|---|
buttons |
Object | An object describing the buttons displayed in the top bar. The object contains two keys, primary and secondary , and each of those keys contain an array of button objects. Primary buttons default to blue, and have a maximum of one button. Secondary buttons have a maximum of four buttons. |
title |
String | The title string displayed in the header behind the application's name. |
pagination |
Object | An object configuring and toggling the pagination arrow button group. |
breadcrumb |
Object | A button object configuring and toggling the breadcrumb in the top bar. Can be applied only if a title has been set. |
Key | Type | Description |
---|---|---|
callback |
Function | When the button is clicked, this function will be executed in the app. |
href |
String | The URL to be opened in the app. |
loading |
Boolean | A boolean value stating if the loading bar should activate when this button is pressed. This defaults to `true`. |
Key | Type | Description |
---|---|---|
src |
String | The URL to be opened in the iframe. |
title |
String | The title of the modal. |
width |
String | Defaults to small . This allows you to set a predetermined width for the modal. The acceptable values are:
large - 980px wide
fullwidth - Fills the width of the screen.
|
height |
Integer | This determines the height of the modal in pixels up to a maximum height of 700px and a minimum of 100px. The height is applied to the body (excluding the header and footer) of the rendered modal. This can also be set from within the modal using the ShopifyApp.Modal.setHeight() method. |
buttons |
Object | An object describing the buttons displayed at the bottom of the modal. The object contains three keys, primary , secondary , and tertiary . Each of those keys contain an array of button objects. Primary buttons default to blue, are floated right, and have a maximum of one button. Secondary buttons are floated right and have a maximum of two buttons. Tertiary buttons are floated left and have a maximum of two buttons. |
callback |
Function | When the modal is closed, this function will be executed in the app. Params are (result, data) . |
Key | Description |
---|---|
accountAccess | Can have 3 possible values: Account owner , Full access , or Limited access . The value will depend on the account access level of the current logged-in user. |
Key | Type | Description |
---|---|---|
label |
String | The text displayed in the button. |
message |
String | The value of the post message that Shopify will send down to the application that can then be listened for. Attributes such as callback and href create these messages manually and do not require this to be set. |
callback |
Function | When the button is clicked, this function will be executed in the app. Params are (message, data) . |
href |
String | The URL to be opened. It should be absolute for Admin links or external links. For links within Shopify it should be of the format /orders/123 . The specific location where this link will be opened depends on the target attribute. |
target |
String | The location where the value of the href will be opened. Default is app . The acceptable values are: new - Open a new window/tab.parent - Replace the current frame/window.shopify - A redirect to within the Shopify admin. A relative path without the admin prefix, like /products .app - Redirects the app's iframe to this URL. Essentially clicking a regular navigation link in the app.
|
loading |
Boolean | A boolean value stating if the loading bar should activate when this button is pressed. Shopify attempts to make a rational guess as to if this should be true or false depending on the action (ie: target: 'new' defaults to false, but target: 'app' defaults to true). It is always safe and prudent to override this value to be exactly what you require for your specific application. |
style |
String | Optional color styling for the button. It will always be a sane default, but can accept danger and disabled . If this is not set, primary buttons appear blue and secondary and tertiary buttons are white. |
type |
String | Sets the button to become a dropdown button. Should be used alongside the links attribute. Current accepted value is dropdown . Only valid for secondary top bar buttons. |
links |
Array | A list of buttons. Accepts the same attributes as a regular button, like label , target and callback . Only valid for secondary top bar buttons. |