Next.js Discord

Discord Forum

SessionProvider and ThemeProvider, which one is the parent?

Unanswered
German yellowjacket posted this in #help-forum
Open in Discord
German yellowjacketOP
I am trying to figure out if I should put the SessionProvider on top of my ThemeProvider or vice versa for my root layout This is what my code currently looks like without the SessionProvider
return (
    <html lang="en">
      <body className={inter.className}>
        <ThemeProvider
          attribute="class"
          defaultTheme="system"
          enableSystem
          disableTransitionOnChange
        >
          {children}
        </ThemeProvider>
      </body>
    </html>
  );
}

2 Replies

Sun bear
It does not really matter unless the <ThemeProvider /> uses something from the <SessionProvider /> and vice versa. I would put <SessionProvider /> as the parent but as I said it does not make a difference
German yellowjacketOP
Ill try that thanks