@shopify/app-bridge
[![Build Status](https://travis-ci.com/Shopify/app-bridge.svg?token=RBRyvqQyN525bnfz7J8p&branch=master)](https://travis-ci.com/Shopify/app-bridge) [![codecov](https://codecov.io/gh/Shopify/app-bridge/branch/master/graph/badge.svg?token=nZ21m39Dr6)](https:
Last updated 4 months ago by shopify-dep .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @shopify/app-bridge 
SYNC missed versions from official npm registry.

@shopify/app-bridge

Build Status codecov License: MIT npm version npm bundle size (minified + gzip)

You can use Shopify App Bridge to embed apps and channels directly into the Shopify admin, Shopify Mobile, and Shopify POS. Shopify App Bridge helps to reduce your development time by accessing native Shopify features across different platforms, and makes sure that the user experience is consistent wherever merchants are using your app.

Shopify App Bridge is currently being released as an update to all current consumers of the Embedded App SDK. Since it’s backwards compatible, you don't need to update your existing apps for them to support Shopify App Bridge.

Installation

You can install Shopify App Bridge by using Yarn:

yarn add @shopify/app-bridge

Usage

Set up your app

In the following example, you need to store shopOrigin during the authentication process and then retrieve it for the code to work properly. To learn more about this process, see Getting and storing the shop origin.

Import the library from the @shopify/app-bridge package and provide a configuration:

import createApp from '@shopify/app-bridge';

const app = createApp({
  apiKey: 'API key from Shopify Partner Dashboard',
  shopOrigin: shopOrigin,
});

Actions

Shopify App Bridge introduces the concept of actions. An action provides a way for applications and hosts to trigger events with a statically-typed payload.

To learn more about the supported actions, see the actions source folder.

App State

Once the app is set up, you can access additional details and the state of the app at any time by making async call app.getState():

app.getState().then((state: any) => {
  console.info('App State: %o', state)
});

You can also use a shorthand to retrieve nested properties by passing in a query when calling getState(query), for example:

app.getState('pos.user').then((user: any) => {
  console.log('POS User: %o', user);
});

Hooks

Shopify App Bridge can be extended with hooks, which run when actions are dispatched and updated. Hooks are middleware that can modify or cancel actions.

To learn more about hooks, see the hooks source code.

Development & Debugging

Shopify App Bridge is shipped with a development build which includes the validation middleware in order to provide helpful information during development.

If you're consuming App Bridge from a CDN or using the UMD build, simply include the development version: umd/index.development.js instead of umd/index.js

When consumed as JS Modules, development/production build is dynamically selected based on the NODE_ENV variable. Development build is used when NODE_ENV=development.

Please note that the development build is not intended for production use, as the resulting file size is significantly larger due to the validator being present.

Contributing

Useful scripts

  • yarn start - Start a development server.
  • yarn build - Build the library, compiling the source TypeScript into JavaScript.
  • yarn clean - Remove any artifacts produced by the build script.
  • yarn lint - Run the source linter.
  • yarn check - Run the TypeScript type checker.

Running the tests

  • yarn test - Run the tests.
  • yarn test:watch - Run the tests in watch mode and auto-rerun on changes.
  • yarn test:coverage - Run the tests and generate a coverage report.

Prettier config

To enable automatic prettier formatting, copy or link the pre-commit script to .git/hooks/pre-commit and make sure that it's executable.

Conventional Commits

Please follow a standardized commit message format when contributing to this repo: https://www.conventionalcommits.org/en/v1.0.0-beta.2/

Current Tags

  • 1.8.0                                ...           latest (2 days ago)
  • 1.8.0-alpha.0                                ...           next (2 days ago)

76 Versions

  • 1.8.0                                ...           2 days ago
  • 1.8.0-alpha.0                                ...           2 days ago
  • 1.7.1                                ...           9 days ago
  • 1.6.9-alpha.0                                ...           a month ago
  • 1.6.8                                ...           a month ago
  • 1.6.8-alpha.0                                ...           2 months ago
  • 1.6.7                                ...           3 months ago
  • 1.6.7-alpha.1                                ...           3 months ago
  • 1.6.6                                ...           4 months ago
  • 1.6.5                                ...           4 months ago
  • 1.6.5-alpha.2                                ...           4 months ago
  • 1.6.5-alpha.1                                ...           4 months ago
  • 1.6.4                                ...           4 months ago
  • 1.6.3                                ...           4 months ago
  • 1.6.2-alpha.0                                ...           4 months ago
  • 1.6.1                                ...           4 months ago
  • 1.6.0-alpha.2                                ...           4 months ago
  • 1.6.0-alpha.1                                ...           4 months ago
  • 1.5.4                                ...           5 months ago
  • 1.5.3                                ...           5 months ago
  • 1.5.2                                ...           5 months ago
  • 1.4.1                                ...           5 months ago
  • 1.4.2-alpha.0                                ...           5 months ago
  • 1.3.1-alpha.8                                ...           5 months ago
  • 1.3.1-alpha.7                                ...           5 months ago
  • 1.3.1-alpha.6                                ...           5 months ago
  • 1.3.1-alpha.4                                ...           5 months ago
  • 1.3.1-alpha.3                                ...           5 months ago
  • 1.3.1-alpha.2                                ...           5 months ago
  • 1.3.1-next.2                                ...           5 months ago
  • 1.3.1-next.1                                ...           5 months ago
  • 1.3.1-next.0                                ...           5 months ago
  • 1.3.0                                ...           6 months ago
  • 1.3.0-next.0                                ...           6 months ago
  • 1.2.1-next.0                                ...           6 months ago
  • 1.2.0                                ...           7 months ago
  • 1.2.0-next.3                                ...           7 months ago
  • 1.2.0-0                                ...           7 months ago
  • 1.1.2                                ...           7 months ago
  • 1.1.0                                ...           7 months ago
  • 1.0.8-0                                ...           7 months ago
  • 1.0.7                                ...           9 months ago
  • 1.0.6                                ...           9 months ago
  • 1.0.5                                ...           9 months ago
  • 1.0.4                                ...           9 months ago
  • 1.0.4-0                                ...           9 months ago
  • 1.0.3                                ...           9 months ago
  • 1.0.3-0                                ...           10 months ago
  • 1.0.2                                ...           10 months ago
  • 1.0.1                                ...           10 months ago
  • 1.0.0                                ...           10 months ago
  • 1.0.0-4                                ...           10 months ago
  • 1.0.0-3                                ...           10 months ago
  • 1.0.0-1                                ...           10 months ago
  • 1.0.0-0                                ...           a year ago
  • 0.8.2                                ...           a year ago
  • 0.8.1                                ...           a year ago
  • 0.8.0                                ...           a year ago
  • 0.7.3                                ...           a year ago
  • 0.7.2                                ...           a year ago
  • 0.7.1                                ...           a year ago
  • 0.7.0                                ...           a year ago
  • 0.6.0                                ...           a year ago
  • 0.5.0                                ...           a year ago
  • 0.4.3                                ...           a year ago
  • 0.4.1                                ...           a year ago
  • 0.4.0                                ...           a year ago
  • 0.3.0                                ...           a year ago
  • 0.2.3                                ...           a year ago
  • 0.2.2                                ...           a year ago
  • 0.2.1                                ...           a year ago
  • 0.1.5                                ...           a year ago
  • 0.1.4                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.2-3                                ...           a year ago

Copyright 2014 - 2016 © taobao.org |