Skip to content

chore(backend,nextjs): Introduce treatPendingAsSignedOut option to server-side utilities and control components #5756

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

LauraBeatris
Copy link
Member

@LauraBeatris LauraBeatris commented Apr 29, 2025

Description

Allow passing treatPendingAsSignedOut to auth, getAuth, and server-side control components.

If session status is pending:

// Returns signed out object by default
const { userId } = auth()
// Treats as signed-in
const { userId } = auth({ treatPendingAsSignedOut: false })

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@LauraBeatris LauraBeatris self-assigned this Apr 29, 2025
Copy link

changeset-bot bot commented Apr 29, 2025

🦋 Changeset detected

Latest commit: 897334b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/nextjs Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Apr 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 5, 2025 8:32pm

@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from adbee6a to e9134ec Compare April 29, 2025 22:25
@LauraBeatris LauraBeatris requested a review from a team April 29, 2025 22:27
@LauraBeatris LauraBeatris marked this pull request as ready for review April 29, 2025 22:29
@LauraBeatris LauraBeatris changed the title chore(nextjs): Introduce treatPendingAsSignedOut to auth and server-side control components chore(nextjs): Introduce treatPendingAsSignedOut to server-side utilities and control components Apr 29, 2025
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from 008dde4 to c66b15e Compare April 29, 2025 22:36
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from c66b15e to adb29b6 Compare April 30, 2025 16:14
@LauraBeatris LauraBeatris marked this pull request as draft April 30, 2025 16:17
@LauraBeatris LauraBeatris changed the title chore(nextjs): Introduce treatPendingAsSignedOut to server-side utilities and control components chore(backend,nextjs): Introduce treatPendingAsSignedOut to server-side utilities and control components Apr 30, 2025
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from 6194b47 to e6ff151 Compare April 30, 2025 17:58
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from 2fd8a5b to 1e8850b Compare April 30, 2025 19:31
@LauraBeatris LauraBeatris marked this pull request as ready for review April 30, 2025 19:39
@LauraBeatris LauraBeatris changed the title chore(backend,nextjs): Introduce treatPendingAsSignedOut to server-side utilities and control components chore(backend,nextjs): Introduce treatPendingAsSignedOut option to server-side utilities and control components May 5, 2025
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from 1e8850b to e955da7 Compare May 5, 2025 20:00
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from e955da7 to 1c7e46d Compare May 5, 2025 20:00
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from 1c7e46d to fc01c62 Compare May 5, 2025 20:01
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from fc01c62 to 3754a5f Compare May 5, 2025 20:14
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from 3754a5f to e3146f1 Compare May 5, 2025 20:17
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from e3146f1 to 44557eb Compare May 5, 2025 20:20
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from 44557eb to f1c99f1 Compare May 5, 2025 20:20
@clerk-cookie clerk-cookie removed the react label May 5, 2025
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from f1c99f1 to af2f6ff Compare May 5, 2025 20:21
@clerk-cookie clerk-cookie removed the types label May 5, 2025
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from af2f6ff to f251a05 Compare May 5, 2025 20:22
@LauraBeatris LauraBeatris force-pushed the laura/orgs-621-sdk-introduce-treatpendingassignedout-option-across-sdk-1 branch from f251a05 to 897334b Compare May 5, 2025 20:31
Comment on lines +61 to +63
if (treatPendingAsSignedOut && authObject.sessionStatus === 'pending') {
authObject = signedOutAuthObject(options, authObject.sessionStatus);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as the Astro PR, I would like to see this come from @clerk/backend:

getAuthObjectFromJwt(jwt)

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

Successfully merging this pull request may close these issues.

3 participants