Next.js Discord

Discord Forum

Error with ThemeProvider from next-themes

Answered
Ocicat posted this in #help-forum
Open in Discord
OcicatOP
Hello, I'm using the latest version of nextjs with typescript and tailwindcss, I'm trying to implement a light/dark mode to my project but I get an error in the “providers.tsx”. The import is done correctly but it has trouble with the {children}, I think it's a typing error with typescript or JSX.

Anyone knows the solution ? Thanks in advance

providers.tsx and layout.tsx in media ->
Answered by Ocicat
bro... thanks, I just understood why it wasn't working, on webstorm I wasn't at the right root when I put npm i next-theme, it created a package.json just before my project folder. I was disgusted.
View full answer

9 Replies

@B33fb0n3 Put your provider inside your body. Also share the full error that you have
OcicatOP
Weird, I also have the latest Next.js version (also latest on TailwindCSS and next-themes) and i tried with your code and it works
Unless you're talking about latest canary version, i have the latest stable: v.15.1.5
@Ocicat Click to see attachment
which version of next-themes are you using?
@Ocicat ?
@B33fb0n3 which version of next-themes are you using?
OcicatOP
latest
@B33fb0n3 which version of next-themes are you using?
OcicatOP
bro... thanks, I just understood why it wasn't working, on webstorm I wasn't at the right root when I put npm i next-theme, it created a package.json just before my project folder. I was disgusted.
Answer