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

Update auth.ts to await params in NextJS 15 #1777

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ammubhave
Copy link

@ammubhave ammubhave commented Oct 4, 2024

  • [N/A] All new/changed/fixed functionality is covered by tests (or N/A)
  • [N/A] I have added documentation for all new/changed functionality (or N/A)

📋 Changes

In NextJS 15, params from routes is now a Promise which must be awaited. Direct access is deprecated and will be removed in future versions.

This change is backwards compatible because awaiting on a non-promise returns back the value itself.

Without this change we get the following warning:

In route /api/auth/[auth0] a param property was accessed directly with `params.auth0`. `params` is now a Promise and should be awaited before accessing properties of the underlying params object. In this version of Next.js direct access to param properties is still supported to facilitate migration but in a future version you will be required to await `params`. If this use is inside an async function await it. If this use is inside a synchronous function then convert the function to async or await it from outside this function and pass the result in.

📎 References

See more details in vercel/next.js#68812

🎯 Testing

Add the SDK in NextJS 15 stable and see that the warning is getting generated whenever the auth0 endpoints are hit.

In NextJS 15, `params` from routes is now a Promise which must be awaited. Direct access is deprecated and will be removed in future versions.

This change is backwards compatible because awaiting on a non-promise returns back the value itself.

Without this change we get the following warning:
```
In route /api/auth/[auth0] a param property was accessed directly with `params.auth0`. `params` is now a Promise and should be awaited before accessing properties of the underlying params object. In this version of Next.js direct access to param properties is still supported to facilitate migration but in a future version you will be required to await `params`. If this use is inside an async function await it. If this use is inside a synchronous function then convert the function to async or await it from outside this function and pass the result in.
```

See more details in vercel/next.js#68812
@ammubhave ammubhave requested a review from a team as a code owner October 4, 2024 16:34
@ammubhave ammubhave changed the title Update auth.ts to await params in preparation for nextjs 15 Update auth.ts to await params in NextJS 15 Oct 21, 2024
Copy link

@Seva98 Seva98 left a comment

Choose a reason for hiding this comment

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

As v15 is officialy out now, why this is still hanging?

@dufferzz
Copy link

Tried this, now getting

Error: Route "/api/auth/[auth0]" used `params.auth0`. `params` should be awaited before using its properties.

Seemingly from 'appRouteHandlerFactory'

Would be great to use Auth0 with Next 15! Exciting

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.

3 participants