firebase / firebase/friendlyeats-web

RootLayout - how to provide currentUser to entire app while maintaining RootLayout as a server component

Open
#305 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
597
Forks
456
PR merge metrics
No merged PRs in 30d

Description

Currently in the RootLayout, the `currentUser` is only provided to the `` component.

Is there a way to "provide" the `currentUser` to the entire app (including `` and its children), without making the RootLayout into a client component so that user related state is available not just in `Header` ?

```
export default async function RootLayout({ children }) {
const { currentUser } = await getAuthenticatedAppForUser();
return (


{children}


);
}

```

There are other Firebase + NextJS examples out there that wrap the entire `` tag in a React Context Provider - still figuring out if it is performant to make the RootLayout into a client component.

Thank you for any insights on this matter.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.