Skip navigation
"How to share state between React client components with a parent server component?"
0:00 / 0:32

"How to share state between React client components with a parent server component?"

Alex Sidorenko

@asidorenko_35K followers

Visit on X
621 likesDownloadOriginal post

51,557 views

"How to share state between React client components with a parent server component?" 👇

9 Comments

Comments from the original post on X (Twitter)

  • 지후's profile picture

    @imjeehoo

    Although it’s quite obvious, you did not add count-provider code

    7 likes

  • chuckstock's profile picture

    @0xChuckstock

    is there a reason for using `use` instead of `useContext`?

    4 likes

  • Alex Sidorenko's profile picture

    @asidorenko_

    nope, same result

    5 likes

  • Kevin Nguyen's profile picture

    @kewinversi

    This vs. Zustand what is your take?

    2 likes

  • Alex Sidorenko's profile picture

    @asidorenko_

    Depends on the type of the app. If it's an interaction-heavy app with a lot of state sharing -> client state lib, if not, context provider here and there is fine

  • Qing | quotion.co's profile picture

    @devrsi0n

    This looks obvious, but what about sharing state between server and client components? I’m using queryparams, not ideal tbh

    1 like

  • Alex Sidorenko's profile picture

    @asidorenko_

    Why not ideal?

  • Carlos Terrazas's profile picture

    @CarlosTerrazasV

    wouldn't it be better to zustand in each client component and thus avoid adding code in the server component? or is it just the demo with contextApi?

  • Alex Aaron Peña's profile picture

    @alexaaronpena

    if the context is defined server side, doesn’t this imply the single context is shared across all users visiting the web app? as I understand if I define a zustand datastore, wrap it in a provider, mount it on a server component, all users will share the same store