Skip to content

Server Side Rendering / Static Site Generation does not have a 'window' in global #218

@ttqftech

Description

@ttqftech

Hey! Is this project still maintaning? I found a problem when using SSR. But the last update is 5 years ago. If you are willing to fix your issues, let me know and I'll try to make a PR.

When using SSR/SSG in a SPA project, it actually renders twice: The first render converts library specified code to rendered HTML at build time or on server, and the second render runs on browser which requires user's browser to execute.

The first render is on server side, which means it is node enviroment, which doesn't have a 'window'. If someone imports your library, it will cause building to fail.
So it's necessary to determine whether the current enviroment is SSR/SSG. If so, only

rendering and 0 wait time is permitted to draw real text. That improves SEO and make initial loading a lot faster. Otherwise, just quit the function call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions