File tree Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
2
* https://nextjs.org/docs/basic-features/environment-variables
3
3
*/
4
- function EnvTest ( ) {
4
+ function EnvTest ( { time } ) {
5
5
return (
6
6
< div >
7
7
< h1 > Environment Variables</ h1 >
8
8
< 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't be exposed to the browser.</ p >
10
9
< p >
11
- < code > NEXT_PUBLIC_</ code > environment variables are available in the browser, and can be used to configure the application.
10
+ By default environment variables are only available in the Node.js environment, meaning they won't be
11
+ exposed to the browser.
12
12
</ 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 >
13
+ < p >
14
+ < code > NEXT_PUBLIC_</ code > environment variables are available in the browser, and can be used to configure the
15
+ application.
16
+ </ p >
17
+ < p >
18
+ ✅ Public Environment token found:{ ' ' }
19
+ < code > { process . env . NEXT_PUBLIC_GREETINGS || 'NOT FOUND (something went wrong)' } </ code >
20
+ </ p >
21
+ < p >
22
+ ❌ Private Environment token should not be found: < code > { process . env . TEST_ENV_VAR ?? 'Everything worked' } </ code >
23
+ </ p >
24
+ < p > Rendered at { time } </ p >
15
25
</ div >
16
26
)
17
27
}
18
28
19
- export default EnvTest
29
+ export const getServerSideProps = async ( { params } ) => {
30
+ return {
31
+ props : {
32
+ time : new Date ( ) . toLocaleDateString ( ) ,
33
+ } ,
34
+ }
35
+ }
36
+
37
+ export default EnvTest
You can’t perform that action at this time.
0 commit comments