Next.js Discord

Discord Forum

RootLayout - button with onCLick

Unanswered
Florida White posted this in #help-forum
Open in Discord
Florida WhiteOP
Hello Guys. I have two problems. I want to create button with onClick and javascript in RootLayout component, can I useclient there or i shouldnt? generally is there a server component so I cant use js and hooks ,sure?

4 Replies

Asian black bear
Can you make a client component wrapping the button and just use that in the root layout?
Florida WhiteOP
I think ,I cant ,because I am using scss modules. I have sideBar on all the pages from RootLayout.

I found one solution ,but i dont know whether it is good...

Look at picture , I added comments to explain what i mean
Asian black bear
you could import a css module directly into the button component file
it doesn't have to be at the page/layout level