Why is this working?
Answered
Ashu posted this in #help-forum

AshuOP
hi, I am using next 14 with page router. This code works:
I've heard I need to use use client directive to use hooks, and by default all components are server. How is this working?
This component is a page
I've heard I need to use use client directive to use hooks, and by default all components are server. How is this working?
This component is a page
index.tsx

11 Replies

AshuOP
Am I missing something?

@Ashu hi, I am using next 14 with page router. This code works:
I've heard I need to use use client directive to use hooks, and by default all components are server. How is this working?
This component is a page `index.tsx`

it should work, there is no server component on page router
Answer

and every component is client component

AshuOP
if that's the case, why am I still able to use the
use client
directive in the page? I mean the use of this is to mark a client component no?But if every page is client comp, why even need one. Or I should not care about it?
it will still work with or without it

AshuOP
Cool, thanks!

AshuOP
@Ray btw what would be an alternate to getServerSideProps in page router?

@Ashu <@743561772069421169> btw what would be an alternate to getServerSideProps in page router?

there is no alternate to
getServerSideProps
if you want to do ssr in page router
AshuOP
okkk thanks!