Next.js Discord

Discord Forum

How to have client components by default in NextJS 13?

Answered
rex1410 posted this in #help-forum
Open in Discord
I am using Chakra UI in my project, and for that the components need to be Client components. For that I will have to add "use client" in all my component files. Is there anyway to make them client components by default?
Answered by fuma
no, it's currently impossible (Next.js doesn't have an option for that)
View full answer

19 Replies

no, it's currently impossible (Next.js doesn't have an option for that)
Answer
@fuma no, it's currently impossible (Next.js doesn't have an option for that)
so I am guessing the only way to tackle this would be

either

put a use client on my top most layout.tsx so that everything below it becomes a client component. But that means I cannot use Metadata and related stuff

OR

downgrade to below nextjs 13 and go ahead with pages router
is that right?
That's wrong, if you mark the root layout as client component, only that layout will be a client component, your pages, children layouts won't be a client component
so the only solution other than putting use client in each file is nextjs <13 ?
And you don't have to downgrade, you can still use Pages Router in Next.js 13
create your pages in pages/ instead of app/
@fuma And you don't have to downgrade, you can still use Pages Router in Next.js 13
but they will again be server components correct?
What do you mean? Server components only exist in App Router
In Pages Router, everything remains the same. No client component, server component, etc.
On the other hand, you can use Pages Router and App Router in the same project
oh wait, I think i misunderstood this concept, so only stuff in the app router is server component by default, which can be made client component by use client.

But in pages router nothing is server or client component by default, but other stuff like SSR stays as it is
Yep
"use client" has no effect in Pages Router, everything is the same as how it used to be
ahhh ok that makes things much more simpler.
@fuma "use client" has no effect in Pages Router, everything is the same as how it used to be
also one more doubt, there is no news of pages router being deprecated or anything is there? 😅
It's not yet deprecated, but not going to have any new changes or features
i see ok, thanks a lot for your help
:blob_hyper: