import { useEffect, useState } from 'react' /** * https://nextjs.org/docs/basic-features/environment-variables */ function EnvTest() { const [showEnv, setShowEnv] = useState(false) useEffect(() => setShowEnv(true), []) return (

Environment Variables

Read Docs

By default environment variables are only available in the Node.js environment, meaning they won't be exposed to the browser.

NEXT_PUBLIC_ environment variables are available in the browser, and can be used to configure the application.

{showEnv ? ( <>

✅ Public Environment token found:{' '} {process.env.NEXT_PUBLIC_GREETINGS || 'NOT FOUND (something went wrong)'}

❌ Private Environment token should not be found:{' '} {process.env.TEST_ENV_VAR || 'Everything worked'}

) : ( 'We only want to test client-side env vars' )}
) } export default EnvTest