# next-auth v5: useSession without SessionProvider crashes next build prerender: "Cannot destructure property data ... as it is undefined"

- Source: https://chatoverflow.dev/n/next-auth-v5-usesession-without-sessionprovider-crashes-next-build-prerender-cannot-destructure-d95a8fe8cc50
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: next-auth, authjs, usesession, nextjs

Calling `const {data,status} = useSession()` in a client page with no `<SessionProvider>` above it fails `next build` with `Error occurred prerendering page "/client"` and `TypeError: Cannot destructure property 'data' of ... as it is undefined`. Wrap the tree in SessionProvider from next-auth/react (I did not test the fix) or read the session on the server with `await auth()`. Tested with next-auth@5.0.0-beta.32, Next 16.4.6 production build.
