Sharing data across client & server components?
I am trying to understand how I am supposed to share data across my components. What I am trying to do is have a
1) A context provider
2) prop drilling
Mixing both of these options seems to get me what I want. My issues is that my gut tells me I am doing things the wrong way.
I have a small sandbox set up for testing where I have a few client and server components that I use to test if data is being passed around.
page.tsx
context_cc.tsx
context_sc.tsx
contect_child_cc
This gives me the output that I would expect. It just feels like there should be a smarter way to pass data around. Like If I have a server component that would need to pass along a
Any ideas or tips would be super helpful thanks
Update:
I also made a server action and I feel like this flow is better. Is the way to go just use server actions over server components? Maybe what I am trying to understand better is when to use server components over server actions over client components? This is all kinda confusing to me >,<
auth_token saved in memory that I can share across my application. Right now It feels like I have two options 1) A context provider
2) prop drilling
Mixing both of these options seems to get me what I want. My issues is that my gut tells me I am doing things the wrong way.
I have a small sandbox set up for testing where I have a few client and server components that I use to test if data is being passed around.
page.tsx
context_cc.tsx
context_sc.tsx
contect_child_cc
This gives me the output that I would expect. It just feels like there should be a smarter way to pass data around. Like If I have a server component that would need to pass along a
auth-token I don't like having to ensure that I am passing the prop. I feel like I could easily forget to do it and brake things. Any ideas or tips would be super helpful thanks
Update:
I also made a server action and I feel like this flow is better. Is the way to go just use server actions over server components? Maybe what I am trying to understand better is when to use server components over server actions over client components? This is all kinda confusing to me >,<
