Loading video...

Video Failed to Load

Go Home

How to use Next.js metadata if the page is a client component

91,579 views • 2 years ago •via X (Twitter)

10 Comments

Alex Sidorenko's profile picture
Alex Sidorenko2 years ago

This is a quick fix for when you are refactoring your codebase to the App Router and want to quickly add metadata to existing pages with interactivity. But ideally, it's better to isolate interactive bits closer to where they're needed.

Guillermo Rauch's profile picture
Guillermo Rauch2 years ago

Love that page.client convention. Clean

Alex Sidorenko's profile picture
Alex Sidorenko2 years ago

Yes! It's from the Next Discord FAQ. Props to Vũ Văn Dũng (not sure what's the right X handle)

عَ's profile picture
عَ2 years ago

Can I do the same thing to call server actions or get cookie information ? 🤔

Alex Sidorenko's profile picture
Alex Sidorenko2 years ago

Server Actions are designed to be used in client components.

Moti Azu's profile picture
Moti Azu2 years ago

You literally made the page not a client component. I like the naming convention you used though. But you didn’t use metadata in a client component.

Ajin's profile picture
Ajin2 years ago

cool

Benzigar Alvin.'s profile picture
Benzigar Alvin.2 years ago

nice idea, wrapping client component inside server component. 👍🏻

rayyan ✦ design engineer's profile picture
rayyan ✦ design engineer2 years ago

i never think of it this way, thanks man

Subhajit Bhar's profile picture
Subhajit Bhar2 years ago

I'm learning next.js. this is very useful for me. Thanks for sharing 🙏🏼

Related Videos