Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 68e4588

Browse files
committed
Updated example
1 parent a856097 commit 68e4588

File tree

1 file changed

+17
-1
lines changed
  • examples/environment-variables/pages

1 file changed

+17
-1
lines changed

examples/environment-variables/pages/index.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,22 @@ const IndexPage = () => (
8181
<pre>
8282
<code>npm run build && npm run start</code>
8383
</pre>
84+
<p>Once you run the app, you'll see logs like these in the terminal:</p>
85+
<pre>
86+
<code>
87+
info - Loaded env from /home/user/../.env.local{'\n'}
88+
info - Loaded env from /home/user/../.env.development{'\n'}
89+
info - Loaded env from /home/user/../.env{'\n'}
90+
</code>
91+
</pre>
92+
<p>
93+
The order is important, the first loaded env will have a higher
94+
priority.
95+
</p>
96+
<p>
97+
<Code>.env</Code> will not overwrite any variables defined in{' '}
98+
<Code>.env.local</Code> or <Code>.env.development</Code>.
99+
</p>
84100
</div>
85101
</div>
86102
)
@@ -92,7 +108,7 @@ export async function getStaticProps() {
92108
// expose environment variables unless they start with `NEXT_PUBLIC_`
93109
console.log('[Node.js only] ENV_VARIABLE:', process.env.ENV_VARIABLE)
94110
console.log(
95-
'[Server only] ENV_LOCAL_VARIABLE:',
111+
'[Node.js only] ENV_LOCAL_VARIABLE:',
96112
process.env.ENV_LOCAL_VARIABLE
97113
)
98114

0 commit comments

Comments
 (0)