Next.js Discord

Discord Forum

Proper way to change document title in use client page?

Answered
Parson Russell Terrier posted this in #help-forum
Open in Discord
Parson Russell TerrierOP
I have a page that needs use client at the top. I realized I cannot use export const metadata as it throws an error. Is the only way to set the title to use document.title =? Or is there another suggested method for use client pages?
Answered by Ray
but I would suggest turning the page component to server component and render a client component
View full answer

6 Replies

Answer
Parson Russell TerrierOP
Ok thank you.

I have components that get passed refs, so is it still possible to remove use client? Because I need to create the refs on the page and I can only create refs on client pages right?
then your page will be something like this
import PageClient from './page.client'

export const metadata = {}

export default function Page() {
  return <PageClient />
}
Parson Russell TerrierOP
Ok thank you