Skip to content

Commit 23838ed

Browse files
committed
ci: don't SSR private env var
1 parent c43522a commit 23838ed

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

demos/default/pages/env.tsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
1+
import { useEffect, useState } from 'react'
2+
13
/**
24
* https://nextjs.org/docs/basic-features/environment-variables
35
*/
46
function EnvTest() {
7+
const [showEnv, setShowEnv] = useState(false)
8+
useEffect(() => setShowEnv(true), [])
59
return (
610
<div>
711
<h1>Environment Variables</h1>
812
<a href="https://nextjs.org/docs/basic-features/environment-variables">Read Docs</a>
9-
<p>By default environment variables are only available in the Node.js environment, meaning they won&apos;t be exposed to the browser.</p>
1013
<p>
11-
<code>NEXT_PUBLIC_</code> environment variables are available in the browser, and can be used to configure the application.
14+
By default environment variables are only available in the Node.js environment, meaning they won&apos;t be
15+
exposed to the browser.
16+
</p>
17+
<p>
18+
<code>NEXT_PUBLIC_</code> environment variables are available in the browser, and can be used to configure the
19+
application.
1220
</p>
13-
<p>✅ Public Environment token found: <code>{process.env.NEXT_PUBLIC_GREETINGS || 'NOT FOUND (something went wrong)'}</code></p>
14-
<p>❌ Private Environment token should not be found: <code>{process.env.TEST_ENV_VAR || 'Everything worked'}</code></p>
21+
{showEnv ? (
22+
<>
23+
<p>
24+
✅ Public Environment token found:{' '}
25+
<code>{process.env.NEXT_PUBLIC_GREETINGS || 'NOT FOUND (something went wrong)'}</code>
26+
</p>
27+
<p>
28+
❌ Private Environment token should not be found:{' '}
29+
<code>{process.env.TEST_ENV_VAR || 'Everything worked'}</code>
30+
</p>
31+
</>
32+
) : (
33+
'We only want to test client-side env vars'
34+
)}
1535
</div>
1636
)
1737
}
1838

19-
export default EnvTest
39+
export default EnvTest

0 commit comments

Comments
 (0)