Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support running on server environments (#199) #208

Merged
merged 3 commits into from
Jun 19, 2022

Conversation

MajorBreakfast
Copy link
Contributor

@MajorBreakfast MajorBreakfast commented Jun 18, 2022

SSR (server-side rendering) is popular these days. Currently it is difficult to import screenful in SvelteKit because the same code is executed both in the browser and on the server. However, screenfull currently errors if document does not exist. Hence, one has to fiddle around to ensure that it is only imported when running in the browser. I assume that this also applies to other SSR solutions like Next.js.

This PR makes it so that screenfull doesn't error on import if document is undefined. If run on the server, screenful doesn't do anything of course (but that's fine :).

Until this PR is merged, I can use version 5.2.0 which supported this use case. That said, it'd be nice to see it return in the newest version.


Fixes #199

@sindresorhus sindresorhus merged commit 2907f62 into sindresorhus:main Jun 19, 2022
@MajorBreakfast MajorBreakfast deleted the patch-1 branch June 21, 2022 19:08
@MajorBreakfast
Copy link
Contributor Author

I've upgraded to the latest version and it works great. Thanks! 🎉

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Whenever I refresh the page I get "document is not defined"
2 participants