Which package is this a feature request for?
Lit Core (lit / lit-html / lit-element / reactive-element), SSR (@lit-labs/ssr)
Description
It would be useful for lit to provide a way to detect if code is running in the server like isSsr so it can be utilized when authoring components to intentionally skip, or provide alternatives for, code that utilizes browser DOM APIs or otherwise are incompatible with SSR.
This is a better alternative to adding no-op DOM shims to alleviate errors during SSR.
Idea for implementation would be to utilize conditional exports to provide a module that will only be available/truthy in node.
cc @aomarks
Alternatives and Workarounds
if (typeof process !== 'undefined'), if(typeof window === 'undefined') 😬 , optional chaining, or relying on no-op DOM shims.