Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: not logged in when rendering SSR #715

Closed
chamatt opened this issue Nov 10, 2022 · 2 comments
Closed

bug: not logged in when rendering SSR #715

chamatt opened this issue Nov 10, 2022 · 2 comments

Comments

@chamatt
Copy link

chamatt commented Nov 10, 2022

Provide environment information

System:
OS: macOS 13.0
CPU: (8) arm64 Apple M1
Memory: 386.59 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.1/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm

Describe the bug

Given a logged-in user, when the page renders server side, the user is not logged in yet, so the page shows the sign-in button. Only when it loads the client side that it fetches the login info and displays it.

Is this the expected behavior? Is there a way to have the session passed in during SSR so that useSession doesn't return null during the ssr render pass?

I saw this PR in the repo where it contained a snippet to passthrough the headers in tRPC (#396), but it's not in the repo anymore (why was it removed?), and that is also not enough.

To reproduce

  • Create a t3-stack repo with next-auth

Additional information

image

@chamatt chamatt changed the title bug: not logged in when SSR bug: not logged in when rendering SSR Nov 10, 2022
@juliusmarminge
Copy link
Member

Get the session on server via gSSP and pass it down as props

@balazsorban44
Copy link
Contributor

Explained here: https://next-auth.js.org/getting-started/client#sessionprovider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants