Next.js Discord

Discord Forum

AuthJS with NextJS latest version question

Unanswered
White Wagtail posted this in #help-forum
Open in Discord
White WagtailOP
I am trying to use NextJS 16 with AuthJS for authorization and i ran into some issues regarding the old middleware and the new proxy files.In the docs it recommends using middleware.ts but nextjs16 isnt fine with that and gives a depracated error.Before just like the docs you could do :
export { auth as middleware } from "@/auth"
in the middleware.ts file but after the change you cant anymore.How is the correct way to migrate the middleware file into a proxy.ts file without losing the same functioning and being correct with new syntax?

10 Replies

American black bear
rename middleware.ts to proxy.ts everything else is the same
but I suggest you drop authjs in favor of better auth or lucia auth as authjs team does some very stupid things like purpesfully making some auth methods harder to implement
@American black bear rename middleware.ts to proxy.ts everything else is the same
Affenpinscher
Hi, are you good at NextAuth.js?
@Affenpinscher Hi, are you good at NextAuth.js?
American black bear
No ive worked with it a long time ago. Best to switch auth solution to reduce the code debt and do your future self a favor.
@American black bear No ive worked with it a long time ago. Best to switch auth solution to reduce the code debt and do your future self a favor.
White WagtailOP
Yea i see a lot of complaints regarding newer versions.So better auth is the most recommended one right
American black bear
yes better auth or lucia auth
lucia is more of a diy and really teaches you a lot about how to implement a good authentication system yorself