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

fix(nextjs-sdk): add support for NextJS 15 #885

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

Conversation

allenzhou101
Copy link
Contributor

@allenzhou101 allenzhou101 commented Jan 8, 2025

Related Issues

Fixes #884

Description

Migrates the SDK to NextJS 15

Must

  • Tests
  • Documentation (if applicable)

@allenzhou101 allenzhou101 changed the title Migration to NextJS 15.1.4 Support NextJS 15 Jan 8, 2025
@allenzhou101 allenzhou101 requested review from asafshen and nirgur and removed request for asafshen January 8, 2025 22:23
Copy link
Member

@asafshen asafshen left a comment

Choose a reason for hiding this comment

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

Cool

Let's see how to solve this issue without breaking BC

// from Next.js 15, headers() returns a Promise
// It can still be used synchronously to facilitate migration
const reqHeaders = headers() as never as HeaderTypes;
export const session = async (): Promise<AuthenticationInfo | undefined> => {
Copy link
Member

Choose a reason for hiding this comment

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

Think break BC
Also for someone that is not using next 15

Let's think about how to achieve that breaking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems to maintain backwards compatibility and access the session synchronously server-side, we would need to switch off of headers, cookies, or any other API from NextJS that is now asynchronous. So doing the same thing where we set the session into whatever storage mechanism (like how it's headers right now) in middleware and accessing via session function.

Options are:

Thoughts on this? At some point we'll probably have to bite the bullet and make the session call async, but maybe once NextJS fully moves off?

Copy link

vercel bot commented Jan 9, 2025

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

Name Status Preview Comments Updated (UTC)
access-key-management-widget ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2025 6:53pm
audit-management-widget ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2025 6:53pm
role-management-widget ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2025 6:53pm
user-management-widget ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2025 6:53pm
user-profile-widget ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2025 6:53pm

@descope descope deleted a comment from vercel bot Jan 9, 2025
Copy link

nx-cloud bot commented Jan 9, 2025

View your CI Pipeline Execution ↗ for commit 017a3d7.

Command Status Duration Result
nx build:app audit-management-widget ✅ Succeeded 24s View ↗
nx build:app access-key-management-widget ✅ Succeeded 26s View ↗
nx build:app user-profile-widget ✅ Succeeded 40s View ↗
nx build:app user-management-widget ✅ Succeeded 26s View ↗
nx build:app role-management-widget ✅ Succeeded 27s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-09 18:53:26 UTC

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

Successfully merging this pull request may close these issues.

Session not working in nextjs 15
3 participants