Are you guys using server components in production ?
Unanswered
Yellowfin tuna posted this in #help-forum
Yellowfin tunaOP
I had some questions regarding server components like
1. is is good idea to use server components for search results and tables do you see changes over client components.
1. is is good idea to use server components for search results and tables do you see changes over client components.
16 Replies
@Yellowfin tuna I had some questions regarding server components like
1. is is good idea to use server components for search results and tables do you see changes over client components.
yea, it can be a good idea to display your pages (tables included) as server component
@B33fb0n3 yea, it can be a good idea to display your pages (tables included) as server component
Yellowfin tunaOP
What about pagination and search with it
@Yellowfin tuna What about pagination and search with it
yea, is also be fine
used to display heave components, like: tables with pagination,
maps, secondary frames etc..
very useful when need to increase webiste performance
maps, secondary frames etc..
very useful when need to increase webiste performance
but be careful with it
@Yellowfin tuna
Yellowfin tunaOP
@Vadym what are things I should be card
@Yellowfin tuna <@1246878836730101771> what are things I should be card
be careful not to include any code that relies on client-side features like window or document.
server components can reduce client side js bundle size, but they might increase server load.
server components can reduce client side js bundle size, but they might increase server load.
@Vadym be careful not to include any code that relies on client-side features like window or document.
server components can reduce client side js bundle size, but they might increase server load.
Just some things to note:
1) You literally cannot have window or any interactive stuff in server side code, react wont allow it so you dont need to be extra careful yourself
2) Client components are also server side rendered just that their interactive side is hydrated on the client
1) You literally cannot have window or any interactive stuff in server side code, react wont allow it so you dont need to be extra careful yourself
2) Client components are also server side rendered just that their interactive side is hydrated on the client
yep
@Yellowfin tunasolved?
@Clown Just some things to note:
1) You literally cannot have window or any interactive stuff in server side code, react wont allow it so you dont need to be extra careful yourself
2) Client components are also server side rendered just that their interactive side is *hydrated* on the client
English Lop
2). point is not always true. The client components won't always be server rendered. They won't be rendered incase if you're using react hooks like useEffect, useContext, useState, etc or accessing browser APIs. You can always cross check this by inspecting View Source section of webpage in browser.
@English Lop 2). point is not always true. The client components won't always be server rendered. They won't be rendered incase if you're using react hooks like useEffect, useContext, useState, etc or accessing browser APIs. You can always cross check this by inspecting View Source section of webpage in browser.
client components are, in fact, server side rendered. @/Clown was right. see also: [Why do Client Components get SSR'd to HTML?](https://github.com/reactwg/server-components/discussions/4) by Dan Abramov, former? member of the React team.
useContext is prerendered on the server using the initial value of the context.
useState is also prerendered, using the initial value of the state.
using browser APIs requires useEffect.
useEffect is not prerendered because it only runs after the first browser rendering is finished.
useContext is prerendered on the server using the initial value of the context.
useState is also prerendered, using the initial value of the state.
using browser APIs requires useEffect.
useEffect is not prerendered because it only runs after the first browser rendering is finished.
@joulev client components are, in fact, server side rendered. @/Clown was right. see also: [Why do Client Components get SSR'd to HTML?](https://github.com/reactwg/server-components/discussions/4) by Dan Abramov, former? member of the React team.
useContext is prerendered on the server using the initial value of the context.
useState is also prerendered, using the initial value of the state.
using browser APIs requires useEffect.
useEffect is not prerendered because it only runs after the first browser rendering is finished.
English Lop
@joulev So Why don't I see the Raw HTML Data in View Source if I'm using these hooks in the perticular components!
@English Lop <@484037068239142956> So Why don't I see the Raw HTML Data in View Source if I'm using these hooks in the perticular components!
your code bug, possibly. without seeing your code i can't guess.
if you want it debugged, i suggest opening a new #help-forum post where people can come see why your component is not being server rendered.
in the meantime i will give you this:
https://github.com/joulev/debug/blob/nextjs-client-component-ssr-example/app/client-components.tsx
https://debug-git-nextjs-client-component-ssr-example-joulev-proj.vercel.app
if you want it debugged, i suggest opening a new #help-forum post where people can come see why your component is not being server rendered.
in the meantime i will give you this:
https://github.com/joulev/debug/blob/nextjs-client-component-ssr-example/app/client-components.tsx
https://debug-git-nextjs-client-component-ssr-example-joulev-proj.vercel.app
@joulev your code bug, possibly. without seeing your code i can't guess.
if you want it debugged, i suggest opening a new <#1007476603422527558> post where people can come see why your component is not being server rendered.
in the meantime i will give you this:
<https://github.com/joulev/debug/blob/nextjs-client-component-ssr-example/app/client-components.tsx>
<https://debug-git-nextjs-client-component-ssr-example-joulev-proj.vercel.app>
English Lop
@joulev Thanks man! I really appreciate this!!