next-auth will run it in the server side, which is why you would need a Confidential client instead of a Public client.
This is how AWS Cognito described different type of clients -
Public client: A native, browser or mobile-device app. Cognito API requests are made from user systems that are not trusted with a client secret.
Confidential client A server-side application that can securely store a client secret. Cognito API requests are made from a central server.