diff --git a/.changeset/three-rings-wash.md b/.changeset/three-rings-wash.md new file mode 100644 index 0000000000..59ce3fbdea --- /dev/null +++ b/.changeset/three-rings-wash.md @@ -0,0 +1,5 @@ +--- +'@clerk/nextjs': patch +--- + +Deprecate `user`, `session`, and `organization` resources from the returned value of `auth()`. diff --git a/packages/nextjs/src/server/getAuth.ts b/packages/nextjs/src/server/getAuth.ts index cf37b83897..c58d3fc0c9 100644 --- a/packages/nextjs/src/server/getAuth.ts +++ b/packages/nextjs/src/server/getAuth.ts @@ -8,6 +8,7 @@ import { signedInAuthObject, signedOutAuthObject, } from '@clerk/backend'; +import { deprecatedObjectProperty } from '@clerk/shared'; import type { SecretKeyOrApiKey } from '@clerk/types'; import { withLogger } from '../utils/debugLogger'; @@ -66,7 +67,22 @@ export const createGetAuth = ({ const jwt = parseJwt(req); logger.debug('JWT debug', jwt.raw.text); - return signedInAuthObject(jwt.payload, { ...options, token: jwt.raw.text }); + + const signedIn = signedInAuthObject(jwt.payload, { ...options, token: jwt.raw.text }); + + if (signedIn.user) { + deprecatedObjectProperty(signedIn, 'user', 'Use `clerkClient.users.getUser` instead.'); + } + + if (signedIn.organization) { + deprecatedObjectProperty(signedIn, 'organization', 'Use `clerkClient.organizations.getOrganization` instead.'); + } + + if (signedIn.session) { + deprecatedObjectProperty(signedIn, 'session', 'Use `clerkClient.sessions.getSession` instead.'); + } + + return signedIn; }; });