build error -next js
Creating an optimized production build ...
Failed to compile.
./node_modules/better-auth/dist/client/react/index.mjs
Attempted import error: 'useRef' is not exported from 'react' (imported as 'React').
Import trace for requested module:
./node_modules/better-auth/dist/client/react/index.mjs
./src/lib/auth-client.ts
./node_modules/better-auth/dist/client/react/index.mjs
Attempted import error: 'useSyncExternalStore' is not exported from 'react' (imported as 'React').
Import trace for requested module:
./node_modules/better-auth/dist/client/react/index.mjs
./src/lib/auth-client.ts
Build failed because of webpack errors
error: script "build" exited with code 1
why am getting this error while building
i am using next.js 15.3.0 and react 19.0.0 and better auth "^1.2.7"
@bekacru @Ping
2 Replies
i already got the solution which was middleware
in middleware i was using authClient
i need to use /client
how can i use it
any one tell me
You are not supposed to use authClient with in the Middleware. authClient do have a client hook and you are trying to use it on server so better to use auth for server related APIs