Next.js Discord

Discord Forum

Why is this working?

Answered
Ashu posted this in #help-forum
Open in Discord
Avatar
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
Image
Answered by Ray
it should work, there is no server component on page router
View full answer

11 Replies

Avatar
Am I missing something?
Answer
Avatar
and every component is client component
Avatar
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
Avatar
Cool, thanks!
Avatar
@Ray btw what would be an alternate to getServerSideProps in page router?
Avatar
@Ashu <@743561772069421169> btw what would be an alternate to getServerSideProps in page router?
Avatar
there is no alternate to getServerSideProps if you want to do ssr in page router
Avatar
okkk thanks!