Server Component not refreshing
Unanswered
Californian posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/3.png)
CalifornianOP
My code:
but the dashboard is not showing after signing in with sign in modal. I guess server component is not refreshing with new data? How can I fix this, because the usession hook works fine but I want to get into habit of using server components
export default async function DashboardPage() {
const session = await getServerSession()
return (
<>
{session ? (
<DashboardModal />
) : (
<p >
Sign in to see this page
</p>
)}
</>
);
}
but the dashboard is not showing after signing in with sign in modal. I guess server component is not refreshing with new data? How can I fix this, because the usession hook works fine but I want to get into habit of using server components
4 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Komondor
This server code isn't tracking any state so it'd have to be re-rendered. Given the fact that it's a DashboardModal, it sounds like this should be a client component. Being a client component, you'd check for a session, if there isn't a session you display "Sign in to see this...". If there is a session you make an API request to the backend for the data needed to hydrate the DashboardModal
I'm pretty new to NextJS but this is how I understand Server components versus Client components
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Japanese flying squid
is ur session null?
![Avatar](https://cdn.discordapp.com/embed/avatars/3.png)
CalifornianOP
We need to run router.refresh() after logging in to fix. But the server component version seems to render the modal slower than client version after logging in.