Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Next.js 13, Why can't I use eventhandler in server component?

In the next.js 13 docs, it says that event handlers cannot be used in server components, but I wonder why. and Why are react hooks not available?

1

like image 688
gndy Br Avatar asked Oct 22 '25 04:10

gndy Br


1 Answers

On the server, there are no user interactions. events are fired based on user interactions. That is why if a component has a button, it should be a client component because someone has to click on that button.

React hooks are related to the browser. they are basically a system that tells browsers when to recalculate certain computations or when to rerender the component based on dependencies. So based on user interactions, your app state will change, and based on this browser has to show the user new interface.

like image 165
Yilmaz Avatar answered Oct 24 '25 09:10

Yilmaz



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!