Describe the bug
Associated bug storybookjs/storybook#32028. In a NextJS app typeof window outputs as undefined.
Steps to reproduce the behavior
- Clone the code locally
git clone https://github.com/robbchar/next-storybook-typeof-repro
- run
yarn install
- run
yarn storybook
- open the dev tools in your browser
- click on the Button story
- notice the output, specifically the line 'typeof window: undefined'
Expected behavior
'typeof window: object' Is in the console
Screenshots and/or logs
'typeof window: undefined' Is in the console
Environment
This should repro everywhere, my system:
- OS: Windows 11
- Node.js version: 22.19.0
- NPM version: 10.9.3
- Browser (if applicable): Chrome
- Browser version (if applicable): 142.0.7444.176
Additional context
I'm opening this so that I can open a PR against it.