_app.js with the app bridge layered in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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