-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Support for Next.JS v15 and changes tocookies()
as well as other API's
#13924
Comments
Hello, @mattiaz9 and thanks for opening this issue. Currently, our NextJS adapter isn't supporting the breaking change that NextJS v15 introduces for the updates to the Async Request API's that will potentially have breaking changes |
Is this going to be a fast update? Being that cookies relate to authenticated fetch requests this causes errors almost everywhere without the ability to ignore specific errors its pretty annoying in dev. Also Next 15 stable was released... this week. |
Hi all, we've started testing the code changes with Next.js v15. Thanks for your patience. |
Thanks for your hard work on this, I know there are many other things going on, so much appreciated. |
Hi all, the Next.js 15 support is now testable with the tag release npm install aws-amplify@next-15 @aws-amplify/adapter-nextjs@next-15 We will continue testing with Next.js 15 to ensure it's stable before the formal release. Please let us know if you encounter any issue while testing, much appreciated! |
I can see the error is no longer getting thrown, so that's great However (and my apologies if this is a separate issue) within the operation when I attempt to
Even though Once the app initializes on the client, amplify correctly detects the user, so my issue is isolated to the server only. Any ideas on what I might've missed / could do to debug? |
Hi @austinjlaverty thanks for following up. For |
Someone else has since opened a ticket for the same thing with next 14, so whatever I've run into probably isn't related to the original async cookies issue. Will continue the conversation there |
Thanks you, maintainers, for publishing the v15-compatible NPM cacary release. |
cookies()
should be awaited before using its value with NextJS 15cookies()
as well as other API's
Hey @HuiSF Our app is broken after upgrading to Next v15 and upgrading the aws-amplify and next adapter with next-15 tag. We have a monorepo setup with:
We're calling the And we're using The catch here is that, So
import { signOut as amplifySignOut } from "@aws-amplify/auth"
import { Amplify } from "aws-amplify"
export const signOut = async ()=>{
console.log(Amplify.getConfig()) // empty object -> {}
await amplifySignOut();
}
"use client";
import { Amplify } from "aws-amplify"
import { signOut } from "@packages/shared/auth"
export const LogoutButton = ()=>{
return <Button onClick={()=>{
console.log(Amplify.getConfig()) // { config: "does exist" }
console.log("-- Before Sign out --")
signOut()
}}
>
Logout
</button>
} and the end output in console is:
|
Hi @akamfoad you analysis is correct regarding this issue. |
Thanks very much @HuiSF that is correct. So for anyone having the same issue, especially in a monorepo setup, yarn was not hoisting Thanks a lot for your prompt response again. |
I'm surprised that the formal Amplify documentation say that Next JS 15 is supported but this is still open and the latest version of the next-adapter does not support Next JS 15. See the official documentation: Amplify support for Next.js I was trying to use the latest version, 1.2.29-next-15.716cf28.0, but it has dependencies clashes with |
Works fine on my project.
|
Hi @hagai-slash-in sorry for the confusing point. The documentation you linked is Amplify Hosting specific. Amplify Hosting supports up to Next.js v15 at this moment. But it's not tightly coupled with Amplify JS library. We have completed testing Amplify JS with Next.js v15, and will release a new version soon. Thanks for your patience. In addition, Amplify UI packages specifies React v18 as peer dependency, while Next.js v15 uses React v19 RC. As far as I know Amplify UI has not completed the compatibility testing yet with React v19 especially it's still in RC. |
Hi all, we've released a new versions of Amplify JS library, which works with Next.js 15 Async Request APIs. Please upgrade packages to the following versions:
Thanks! |
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
None
Environment information
Describe the bug
In the latest nextjs canary, cookies and headers are async, so they must be awaited.
This is the error it shows in console:
In route /dashboard a cookie property was accessed directly with
cookies().get('CognitoIdentityServiceProvider.xxxxxxxxxxxxxxxxxxxxx.LastAuthUser').
cookies()should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
code:
Expected behavior
Cookies should be awaited and no error should be shown in console.
Reproduction steps
getCurrentUser
inside a react server componentCode Snippet
// Put your code below this line.
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: