Skip to content

Instantly share code, notes, and snippets.

@nutterbrand
Last active January 3, 2021 04:00
Show Gist options
  • Save nutterbrand/eda9c460980148a03f2faf909edf4c37 to your computer and use it in GitHub Desktop.
Save nutterbrand/eda9c460980148a03f2faf909edf4c37 to your computer and use it in GitHub Desktop.
_app.js with the app bridge layered in
import React from 'react';
import App from 'next/app';
import Head from 'next/head';
import { AppProvider } from '@shopify/polaris';
import { Provider } from '@shopify/app-bridge-react';
import '@shopify/polaris/dist/styles.css';
import translations from '@shopify/polaris/locales/en.json';
class MyApp extends App {
render() {
const { Component, pageProps, shopOrigin } = this.props;
const config = { apiKey: API_KEY, shopOrigin, forceRedirect: true };
return (
<React.Fragment>
<Head>
<title>Sample App</title>
<meta charSet="utf-8" />
</Head>
<Provider config={config}>
<AppProvider i18n={translations}>
<Component {...pageProps} />
</AppProvider>
</Provider>
</React.Fragment>
);
}
}
MyApp.getInitialProps = async ({ ctx }) => {
return {
shopOrigin: ctx.query.shop,
}
}
export default MyApp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment