Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle SEO for client components in Next.js 13?

I'm confused on how to manage SEO for client components in Next.js 13.

Let's say I want to create a contact us page at /contact

In the new framework, I should create a folder named contact inside the app directory. And in it I should create a page called page.js by convention.

Now I need to create a form, which of course needs to manage its state. Thus I should use useState or other hooks from react.

But when I do that, Next.js compiler complains that it's a server component and if I want to use it on the client-side, I should mark it with 'use client' directive at the top.

But I don't want the component to be rendered on the client-side. I need my /contact page to be indexed by search engines.

What should I do?

like image 364
Big boy Avatar asked Dec 31 '25 19:12

Big boy


1 Answers

use client does not mean that your component will be rendered on client only.

It works as previous versions of Next.js.

It will be rendered on server and hydrated on client.

like image 135
Sefa Kocaaga Avatar answered Jan 03 '26 11:01

Sefa Kocaaga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!