admin管理员组文章数量:1404927
Out of curiosity, shadcn's sidebar has 'use client' declaration on the top of its component file which includes the declaration of SidebarProvider
.
From my understanding of nextjs, when a client component is rendered, all of its children are rendered on the client side too.
But the shadcn documentation encourages to wrap out entire application with the SidebarProvider
.
Does this not render our entire app on the client side and kill ssr as a whole?
I am pretty sure this is not the case, but how does this SidebarProvider
work under the hood?
Out of curiosity, shadcn's sidebar has 'use client' declaration on the top of its component file which includes the declaration of SidebarProvider
.
From my understanding of nextjs, when a client component is rendered, all of its children are rendered on the client side too.
But the shadcn documentation encourages to wrap out entire application with the SidebarProvider
.
Does this not render our entire app on the client side and kill ssr as a whole?
I am pretty sure this is not the case, but how does this SidebarProvider
work under the hood?
- just read the nextjs doc nextjs./docs/app/building-your-application/rendering/… I guess this is fine because the server components are passed as children? – Tenshi Munasinghe Commented Mar 9 at 8:43
1 Answer
Reset to default 1use client
does not mean that the server side rendering is gone/killed. As mentioned in this dicussion, client components are also rendered on the server, just that they are also interactive.
How else will we use useEffect and other client side hooks in components, if they do not run on the client once.
And yes, as you already mentioned in the comment that server components can be passed into client components as props. A simpler mental model is explained here
本文标签: javascriptDoes shadcn SidebarProvider render all its children on the client on NextjsStack Overflow
版权声明:本文标题:javascript - Does shadcn SidebarProvider render all its children on the client on Next.js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744875683a2629901.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论