TypeError: r is not a function #9251
Replies: 11 comments 23 replies
-
If your using App Router I recommend to watch this video https://youtu.be/md65iBX5Gxg?si=Qa2vL0uxL4cYj8pt and also you don't need to use the beta version they are unstable I figured it out yesterday. So saving you the trouble |
Beta Was this translation helpful? Give feedback.
-
same error |
Beta Was this translation helpful? Give feedback.
-
I had "next-auth": "^5.0.0-beta.4", |
Beta Was this translation helpful? Give feedback.
-
uninstalling the beta version("^5.0.0-beta.4") and reinstalling stable version("4.24.5") worked for me too. |
Beta Was this translation helpful? Give feedback.
-
After this just hit |
Beta Was this translation helpful? Give feedback.
-
This helped me too! So what is wrong with the beta version of next-auth. This versions hell with nextjs-14 drives me crazy |
Beta Was this translation helpful? Give feedback.
-
Since you are using next auth v5, I've solved it like this:
export const { auth, signIn, signOut, handlers: { GET, POST } } = NextAuth({
// Your Auth config here
});
export { GET, POST } from "@/auth"; // change the route to the auth.ts path if it's not the same You have to make sure that all of your config for auth is inside |
Beta Was this translation helpful? Give feedback.
-
try this link: https://authjs.dev/getting-started/migrating-to-v5 i got the same error and its work for me. problably u forget auth.ts file main folder project |
Beta Was this translation helpful? Give feedback.
-
In my case reason of this error is replacement from const {
handlers: { GET, POST },
auth,
signIn,
signOut,
} = NextAuth(authConfig); // static object to const buildAuthConfig = (request?: NextRequest) => { // my logic }
const {
handlers: { GET, POST },
auth,
signIn,
signOut,
} = NextAuth(buildAuthConfig); And I don't know how to fix that, return back to static config for now. |
Beta Was this translation helpful? Give feedback.
-
I resolve this issue! // src/auth/index.ts
import NextAuth, { NextAuthConfig } from "next-auth";
import Google from 'next-auth/providers/google';
export const BASE_PATH = "/api/auth";
const authOptions: NextAuthConfig = {
providers: [
Google({
clientId: process.env.GOOGLE_CLIENT_ID ?? '',
clientSecret: process.env.GOOGLE_CLIENT_SECRET ?? ''
})
],
basePath: BASE_PATH,
};
export const { handlers: { GET, POST }, auth, signIn, signOut } = NextAuth(authOptions); // src/auth/helpers.ts
"use server";
import { signIn as SignIn, signOut as SignOut } from "./index";
export async function signIn() {
await SignIn();
}
export async function signOut() {
await SignOut();
} If you want to see whole code, you can visit my repository commit log |
Beta Was this translation helpful? Give feedback.
-
Mine occurred due to the AI Coding assistant (Claude - Haiku) adding a 'use client' directive to the route.ts handler file. Check for this in your route handlers. (I am using "next": "14.2.18", with "next-auth": "^5.0.0-beta.25"). |
Beta Was this translation helpful? Give feedback.
-
I am facing many problems with next-auth@beta and next js 14. After redirect back from discord oauth I am getting this error
"TypeError: r is not a function"
Beta Was this translation helpful? Give feedback.
All reactions