Skip to content

window is not defined on SSR with Nuxt UI <UButton> #39

Open
@MickL

Description

@MickL

Environment

- Operating System: Darwin
- Node Version:     v21.6.1
- Nuxt Version:     3.11.2
- CLI Version:      3.11.1
- Nitro Version:    2.9.6
- Package Manager:  [email protected]
- Builder:          -
- User Config:      devtools, modules, routeRules, i18n
- Runtime Modules:  @nuxt/ui@^2.15.2, @nuxt/fonts@^0.6.1, @nuxtjs/[email protected], @sidebase/nuxt-pdf@^1.0.0-alpha.0
- Build Modules:    -

Reproduction

No response

Describe the bug

This works:

<button @click="exportToPDF('filename.pdf', pdfContent)">Create PDF</button>

This throws an error:

<UButton @click="exportToPDF('filename.pdf', pdfContent)">Create PDF</UButton>

On SSR it throws window is not defined from node_modules/jspdf/dist/jspdf.min.js:171:8032. When opening another page and then navigating to the page that contains the above code it works, e.g.:

  • /pdf -> error
  • /another-page -> /pdf -> works

Additional context

No response

Logs

No response

Btw. I wonder if this project is still maintained? According to #11 custom fonts dont work and pdf size is 8mb instead of 400kb.

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