Currently, I am working on Nextjs 14 with typescript and implementing authentication and authorization using Clerk. Following the instructions in the Clerk documentation, I included the code snippet below in my middleware.ts file:
import { authMiddleware } from "@clerk/nextjs";
export default authMiddleware({});
export const config = {
matcher: ["/((?!.+.[w]+$|_next).*)", "/", "/(api|trpc)(.*)"],
};
However, when I later tried to add protected routes as per the Clerk documentation, I encountered the message:
This method is now deprecated. Please use clerkMiddleware() instead.
You can find more information in the docs:
Upon updating my middleware.ts file with clerkMiddleware(), I received the following error:
'"@clerk/nextjs/server"' has no exported member named 'clerkMiddleware'. Did you mean 'WithClerkMiddleware'?ts(2724)
In an attempt to resolve this issue, I also ran the command:
npm i clerk@latest
Could someone advise me on how to address this error effectively?