Build error after migrating to React 19 and Next.js 15
Getting this error after migrating to react 19 and nextjs 15.
As well as an error making me download the
oslo
package
Here are the dependencies I updated:
8 Replies
don't use
authClient
in next middleware. If you need to create a new authClient from the native path. Meaning
That fixed it for me, but may i ask why its client and not react? Because in the documentation its being imported from /react, so is the documentation outdated or am I missing something?
Just an assumption:
/react
is still correct, but only for code environments ran with React.
Next middleware doesn't work with React, so you must use the /client
version.I see, for now i changed my whole auth client to /client and it’s working fine so far on Next.js 15. If i started facing problems the i can just create an auth client specific for middleware
Yeap.
you should just create auth client from /client just for the middleware so you can have
useSession
for react in other parts of your appUnknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Yeah i think it should be included in the middleware part of the documentation for nextjs
https://www.better-auth.com/docs/integrations/next#middleware
Next.js integration | Better Auth
Integrate Better Auth with Next.js.