Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docs - Theming): Resolving Issue "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used" #6006

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
21 changes: 13 additions & 8 deletions apps/www/content/docs/dark-mode/next.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ npm install next-themes
### Create a theme provider

```tsx title="components/theme-provider.tsx"
"use client"
'use client'

import * as React from "react"
import { ThemeProvider as NextThemesProvider } from "next-themes"
import { type ThemeProviderProps } from 'next-themes'
import dynamic from 'next/dynamic'
import * as React from 'react'

export function ThemeProvider({
children,
...props
}: React.ComponentProps<typeof NextThemesProvider>) {
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
const NextThemesProvider = dynamic(
() => import('next-themes').then((e) => e.ThemeProvider),
{
ssr: false,
}
)

export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
}
```

Expand Down