Build a custom provider component nextjs appdir

Hello. I want to make a react component which when passes as a parent to another, the child will automatically have a certain prop I want to pass.
e.g The ProvideAuth component

<ProvideAuth>
<HomePage />
</ProvideAuth>


<ProvideAuth>
<Profile />
</ProvideAuth>


The ProvideAuth (server) component would be responsible for fetching the user and authenticating the user at the same time, it passes the user data(if found) to both the HomePage and the Profile component. So I would be able to do this in the Homepage component

'use client'

function HomePage({user}){
return <div> Hello {user.name}</div>

}
Was this page helpful?