After switching to Next 16+ we get this error when swiching language. This issue also mentions the error and possible solutions: pacocoursey/next-themes#387. To me it seems like the best option is switching from next-themes to the maintained fork @teispace/next-themes. By swapping the dependency and imports, the issue is fixed with no further code changes.
Error Type
Console Error
Error Message
Encountered a script tag while rendering React component. Scripts inside React components are never executed when rendering on the client. Consider using template tag instead (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template).
at script (unknown:0:0)
at ThemeProvider (src/components/providers/ThemeProvider.tsx:7:5)
at RootProviders (src/components/providers/RootProviders.tsx:17:5)
at LocaleLayout (src/app/[locale]/layout.tsx:104:9)
Code Frame
5 | function ThemeProvider({ children }: { children: React.ReactNode }) {
6 | return (
7 | <NextThemeProvider
| ^
8 | attribute='class'
9 | defaultTheme='system'
10 | enableSystem
Next.js version: 16.2.4 (Turbopack)
After switching to Next 16+ we get this error when swiching language. This issue also mentions the error and possible solutions: pacocoursey/next-themes#387. To me it seems like the best option is switching from next-themes to the maintained fork @teispace/next-themes. By swapping the dependency and imports, the issue is fixed with no further code changes.
Error Type
Console Error
Error Message
Encountered a script tag while rendering React component. Scripts inside React components are never executed when rendering on the client. Consider using template tag instead (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template).
Code Frame
5 | function ThemeProvider({ children }: { children: React.ReactNode }) {
6 | return (
Next.js version: 16.2.4 (Turbopack)