Skip to content

[Bug] typeof window is undefined, but window exists (dupe from storybook 32028) #79

@robbchar

Description

@robbchar

Describe the bug

Associated bug storybookjs/storybook#32028. In a NextJS app typeof window outputs as undefined.

Steps to reproduce the behavior

  1. Clone the code locally git clone https://github.com/robbchar/next-storybook-typeof-repro
  2. run yarn install
  3. run yarn storybook
  4. open the dev tools in your browser
  5. click on the Button story
  6. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions