Next.js Discord

Discord Forum

Export conditionally in _app.js?

Unanswered
American Bobtail posted this in #help-forum
Open in Discord
Avatar
American BobtailOP
This is from the _app.js, pages directory
App.getInitialProps = async ({ Component, ctx, ...rest }) => {
  const path = ctx.pathname;
  const isWebView = webviewRoutes.includes(path);
  return {
    pageProps: {
      ...(Component.getInitialProps
        ? await Component.getInitialProps(ctx)
        : {}),
      appProp: path,
      isWebView,
    },
    ...(!isWebView && { isAuth: isAuth(ctx) }),
  };
};

export default wrapper.withRedux(App);


What I'm trying to do is not initialize Redux at all when it's a webview and just export the App, I still can't wrap my head around it, any help would be appreciated!


This is from the App component it self
  if (isWebView) {
    return (
      <WebviewGlobalComponent>
        <Component {...pageProps} />
      </WebviewGlobalComponent>
    );
  } else {
          return (
        <AuthProvider>
          <Layout isAuth={rest.isAuth}>
            <Provider store={store}>
              <SnackbarProvider>
                <Component {...pageProps} isAuth={rest.isAuth} />
              </SnackbarProvider>
            </Provider>
          </Layout>
        </AuthProvider>
      )
}

2 Replies

Avatar
American BobtailOP
bump
Avatar
American BobtailOP
bump