withAuth module not exported in next-auth in Next.js

Viewed 1000

I am trying to add a middleware in the route /admin at next.js, and in the file " _middleware.js" it is like this:

    import { withAuth } from "next-auth/middleware";

export default withAuth({
  callbacks: {
    authorized({ req, token }) {
      if (token) return true; // If there is a token, the user is authenticated
    },
  },
});

Error:

./pages/admin/_middleware.js:1:0
Module not found: Package path ./middleware is not exported from package

Path:

    pages
    |-------admin
    |--------------_middleware.js
    |--------------index.js
1 Answers
Related