Skip to content

How to make it work with Next.js (SSG especially) #90

Answered by Maatzu
jamfive asked this question in Q&A
Discussion options

You must be logged in to vote

No i'ts just that you can define it with "use client". But if you are on the traditional pages directory you can try this:

export default function App({ Component, pageProps }: AppPropsWithLayout) {
  const [isClient, setIsClient] = useState(false);
  useEffect(() => setIsClient(true), []);

  const router = useRouter();

  const Layout = Layouts[Component.Layout] ?? ((page) => page);
  return (
    isClient && (
      <AuthProvider authConfig={authConfig(router)}>
        <RootLayout>
          {Component.Layout ? (
            <Layout>
              <Component {...pageProps} />
            </Layout>
          ) : (
            <Component {...pageProps} />
          )}
        </RootLayout>

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@Maatzu
Comment options

Answer selected by sebastianvitterso
@jamfive
Comment options

@Maatzu
Comment options

@soofstad
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants