Next.js Discord

Discord Forum

"use client" but still console.log() prints to terminal

Answered
Philippine Crocodile posted this in #help-forum
Open in Discord
Philippine CrocodileOP
Hi, very basic question from a beginner here: I'm following a llamadev tutorial (https://www.youtube.com/watch?v=VE8BkImUciY&t=578s), and am at the point where he demo's client side vs. server side rendering with "use client".

In my case however, my VSCode terminal (where I invoked npm run dev) continues to print the console.log("hello") statement even after I add "use client" when I refresh the development-server running in Chrome. I can't quite tell if this is expected due to some other setting, but it makes me thing client side rendering isn't working.

Here is my footer component:
And here is my layout.js where it's used...
Answered by American Chinchilla
On page load, next renders a static preview on the server for both server and client components

https://nextjs.org/docs/app/building-your-application/rendering/client-components#how-are-client-components-rendered
View full answer

3 Replies

American Chinchilla
On page load, next renders a static preview on the server for both server and client components

https://nextjs.org/docs/app/building-your-application/rendering/client-components#how-are-client-components-rendered
Answer
American Chinchilla
If you had an onClick in your footer that had a console.log you'd expect to see that in the browser console
Philippine CrocodileOP
understood, thank you!