Closed mjawhariPT closed 6 months ago
Good day @mjawhariPT :)
OverlayScrollbars is able to run on the server without problems. The problem here is the RSC expectation to run only on the server.
When using "use client"
aka. Client Components
in NextJs it doesn't mean that the component is runnung only on the client. It means that the component could be run on the client and on the server for server side rendering. What "use client"
indicates is that the components javascript will be included in the clients bundle because it possibly could be executed there.
Now to "use server"
aka. Server Conponents
. This indicates that the component will be run only on the server and never on the client. With such components the javascript needed for rendering on the server will not be in included in the client bundle. This makes sense for components which are static and require no client side javascript. Since OverlayScrollbars
is a javascript library which is intended to run on the client (but can also be run on the server for ssr) you'll need to use the "use client"
annotation for it. This just means that the components javascript is expected to be executed also on the client and doesnt mean that the component wont run on the server.
Ah that makes sense, thank you for the thorough explanation!
I am trying to use
overlayscrollbars-react
with NextJS 13. I want to replace the scrollbar for mybody
element, so my code looks like this:However, this gives me an error telling me that the
OverlayScrollbarsComponent
uses a functionality that's only available to client components, despite the docs saying that this library can be run on the server:Am I doing something wrong? Thanks!