Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

unstable_getServerSession() not working with nextjs13 #5759

Closed
VaquarShaikh opened this issue Nov 8, 2022 · 5 comments
Closed

unstable_getServerSession() not working with nextjs13 #5759

VaquarShaikh opened this issue Nov 8, 2022 · 5 comments
Labels
incomplete Insufficient reproduction. Without more info, we won't take further actions/provide help. triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@VaquarShaikh
Copy link

VaquarShaikh commented Nov 8, 2022

Environment

System: OS: Windows 10 10.0.22000 CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz Memory: 1.06 GB / 7.89 GB Binaries: Node: 19.0.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD npm: 8.5.3 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: 107.0.5304.88 Edge: Spartan (44.22000.120.0), Chromium (107.0.1418.35) Internet Explorer: 11.0.22000.120 npmPackages: next: 13.0.2 => 13.0.2 next-auth: ^4.16.4 => 4.16.4 react: 18.2.0 => 18.2.0

Reproduction URL

#5741

Describe the issue

Hi , I am trying to load session in nextjs13 , unstable_getserversession does not seem to work , I have followed the thread exactly and it gives me the following error

Unhandled Runtime Error Error: PrismaClient is unable to be run in the browser. In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues

This error comes after resolving a previous error

Cant find module v8

I installed v8 library using yarn add v8

after that I encountered prismaclient error.

How to reproduce

Below is the code snippet I am trying to run

`
import { unstable_getServerSession } from "next-auth";
import { signIn, useSession } from "next-auth/react";
import Head from "next/head";
import Image from "next/image";
import styles from "../../styles/Home.module.css";
import { authOptions } from "./api/auth/[...nextauth]";

export default function Home() {
const session = unstable_getServerSession(authOptions);
return (


<button onClick={() => signIn("google")}>Signin

);
}
`

Expected behavior

It should load session on server component .

@VaquarShaikh VaquarShaikh added the triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. label Nov 8, 2022
@VaquarShaikh
Copy link
Author

`
import { unstable_getServerSession } from "next-auth";
import { signIn, useSession } from "next-auth/react";
import Head from "next/head";
import Image from "next/image";
import styles from "../../styles/Home.module.css";
import { authOptions } from "./api/auth/[...nextauth]";

export default function Home() {
const session = unstable_getServerSession(authOptions);
return (


<button onClick={() => signIn("google")}>Signin

);
}

`
This is the snipppet i am using

@marcostoduto

This comment was marked as off-topic.

@balazsorban44 balazsorban44 added the incomplete Insufficient reproduction. Without more info, we won't take further actions/provide help. label Nov 8, 2022
@balazsorban44
Copy link
Member

balazsorban44 commented Nov 8, 2022

please provide a proper reproduction. are you using the edge runtime?

@zenflow
Copy link
Contributor

zenflow commented Nov 9, 2022

This error comes after resolving a previous error
Cant find module v8
I installed v8 library using yarn add v8

This is a real issue too, which I haven't gotten past because I don't want to install the "v8" package from npm which is clearly not the right "v8" module (and I don't know if it's safe): https://www.npmjs.com/package/v8

Here's the console log:

error - ./node_modules/openid-client/lib/helpers/deep_clone.js:1:33
Module not found: Can't resolve 'v8'

Import trace for requested module:
./node_modules/openid-client/lib/issuer.js
./node_modules/openid-client/lib/index.js
./node_modules/next-auth/core/lib/oauth/callback.js
./node_modules/next-auth/core/routes/callback.js
./node_modules/next-auth/core/routes/index.js
./node_modules/next-auth/core/index.js
./node_modules/next-auth/next/index.js
./node_modules/next-auth/index.js
./pages/_app.tsx

https://nextjs.org/docs/messages/module-not-found

The import trace points to this line in "openid-client":
https://github.com/panva/node-openid-client/blob/35c6566625e0d1238b8ce14c0544b05c488197d3/lib/helpers/deep_clone.js#L1

I think the "v8" module it's trying to require is the native Node.js "v8" module: https://nodejs.org/docs/latest-v18.x/api/v8.html

I can require('v8') in the Node.js REPL just fine, so not sure why Next.js can't resolve the module.

Versions:

  • Node.js 18.12.0
  • Next.js 13.0.2
  • NextAuth.js 4.16.4

Not using Turbopack or any experimental Next.js features

@balazsorban44
Copy link
Member

balazsorban44 commented Nov 11, 2022

Still, please add a reproduction. You likely use experimental-edge, or trying to use unstable_getServerSession in pages.

I'm converting this to a discussion, since this is not a NextAuth.js bug.

@nextauthjs nextauthjs locked and limited conversation to collaborators Nov 11, 2022
@balazsorban44 balazsorban44 converted this issue into discussion #5794 Nov 11, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
incomplete Insufficient reproduction. Without more info, we won't take further actions/provide help. triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

4 participants