Skip to content

Conversation

@Rich-Harris
Copy link
Member

This adds an $app/env module that exports browser and dev:

<script>
  import { browser, dev } from '$app/env';
</script>

<p>Hello from the {browser ? 'client' : 'server'} in {dev ? 'dev' : 'prod'} mode!</p>

Right now, browser = typeof window !== 'undefined' which is brittle (would fail if someone did global.window = 42). Ideally we'd use import.meta.env.SSR instead but there's a blocker (#194).

I'm anticipating that amp would go here too if we do #160.

@Rich-Harris Rich-Harris merged commit ed6b8fd into master Dec 10, 2020
@Rich-Harris Rich-Harris deleted the env branch December 10, 2020 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants