Skip navigation
How to use Next.js metadata if the page is a client component
0:00 / 0:33

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

Alex Sidorenko

@asidorenko_35K followers

Visit on X
1,103 likesDownloadOriginal post

91,579 views

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

10 Comments

Comments from the original post on X (Twitter)

  • Alex Sidorenko's profile picture

    @asidorenko_

    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.

    28 likes

  • Guillermo Rauch's profile picture

    @rauchg

    Love that page.client convention. Clean

    59 likes

  • Alex Sidorenko's profile picture

    @asidorenko_

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

    21 likes

  • عَ's profile picture

    @Pathfinde_r

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

    2 likes

  • Alex Sidorenko's profile picture

    @asidorenko_

    Server Actions are designed to be used in client components.

    1 like

  • Moti Azu's profile picture

    @MotiAzu

    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.

    2 likes

  • Ajin's profile picture

    @ChandyAjin

    cool

    2 likes

  • Benzigar Alvin.'s profile picture

    @benzigar_alvin

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

    1 like

  • rayyan ✦ design engineer's profile picture

    @rayyanekaputra

    i never think of it this way, thanks man

    1 like

  • Subhajit Bhar's profile picture

    @JitWrites

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

    1 like