Wasay Syed

Senior Programmer & Web Developer

Published

January 30, 2023

Author

U
Unknown

Property 'user' does not exist on type '{}' - NextJS - NextAuth Error

For NextJS framework the method name unstable_getServerSession was renamed to getServerSession. You can see the documentation on the following page.Next.js | NextAuth.js (next-auth.js.o...

For NextJS framework the method name unstable_getServerSession was renamed to getServerSession. You can see the documentation on the following page.

Next.js | NextAuth.js (next-auth.js.org)


The code that generated the error for me was:

if (!session?.user.id) return res.status(401).end("Unauthorized");

And the error messages were:

unstable_getServerSession deprecated symbol used

Type error: Property 'user' does not exist on type '{}'.