正在加载视频...

视频加载失败

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

91,579 次观看 • 2 年前 •via X (Twitter)

10 条评论

Alex Sidorenko 的头像
Alex Sidorenko2 年前

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 的头像
Guillermo Rauch2 年前

Love that page.client convention. Clean

Alex Sidorenko 的头像
Alex Sidorenko2 年前

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

عَ 的头像
عَ2 年前

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

Alex Sidorenko 的头像
Alex Sidorenko2 年前

Server Actions are designed to be used in client components.

Moti Azu 的头像
Moti Azu2 年前

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 的头像
Ajin2 年前

cool

Benzigar Alvin. 的头像
Benzigar Alvin.2 年前

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

rayyan ✦ design engineer 的头像
rayyan ✦ design engineer2 年前

i never think of it this way, thanks man

Subhajit Bhar 的头像
Subhajit Bhar2 年前

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

相关视频