Next.js, ReferenceError: sessionStorage is not defined during build

I’m using Next.js 13 App router. I was storing the JWT token I received on login in session storage. I was able to access the token in all of my page.js pages in all of my routes if the page.js for that specific route/folder was a client component. This worked fine during dev, ie when i ran with npm run dev , but when i took the build , ie, next build it failed and gave me the error ReferenceError: sessionStorage is not defined .

Is it necessary that in Next.js the page.js for every route be server components rather than client. Are they considered as server components during build??