-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: 03-pages > 02-api-reference > 03-next-config-js > env.mdx #346
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,20 +1,20 @@ | ||||||
--- | ||||||
title: env | ||||||
description: Learn to add and access environment variables in your Next.js application at build time. | ||||||
title: 환경 변수 | ||||||
description: 빌드 시 Next.js 애플리케이션에서 환경 변수를 추가하고 액세스하는 방법을 알아보세요. | ||||||
--- | ||||||
|
||||||
> Since the release of [Next.js 9.4](https://nextjs.org/blog/next-9-4) we now have a more intuitive and ergonomic experience for [adding environment variables](/docs/pages/building-your-application/configuring/environment-variables). Give it a try! | ||||||
> [Next.js 9.4](https://nextjs.org/blog/next-9-4)의 출시 이후로 [환경 변수 추가하기](/docs/pages/building-your-application/configuring/environment-variables)가 더 직관적이고 사용하기 쉽습니다. 한번 시도해 보세요! | ||||||
|
||||||
<details> | ||||||
<summary>Examples</summary> | ||||||
<summary>예제</summary> | ||||||
|
||||||
- [With env](https://github.com/vercel/next.js/tree/canary/examples/with-env-from-next-config-js) | ||||||
- [env 활용하기](https://github.com/vercel/next.js/tree/canary/examples/with-env-from-next-config-js) | ||||||
|
||||||
</details> | ||||||
|
||||||
> **Good to know**: environment variables specified in this way will **always** be included in the JavaScript bundle, prefixing the environment variable name with `NEXT_PUBLIC_` only has an effect when specifying them [through the environment or .env files](/docs/pages/building-your-application/configuring/environment-variables). | ||||||
> **알아두면 좋은 사실**. 이런 방식으로 지정된 환경 변수들은 **항상** 자바스크립트 번들에 포함됩니다. 환경 변수 이름 앞에 `NEXT_PUBLIC_`를 붙이는 것은 그것들을 [환경 또는 .env 파일을 통해](/docs/pages/building-your-application/configuring/environment-variables) 지정할 때만 효과가 있습니다. | ||||||
|
||||||
To add environment variables to the JavaScript bundle, open `next.config.js` and add the `env` config: | ||||||
자바스크립트 번들에 환경 변수를 추가하려면 `next.config.js`를 열고 `env` 설정을 추가하세요. | ||||||
|
||||||
```js filename="next.config.js" | ||||||
module.exports = { | ||||||
|
@@ -24,7 +24,7 @@ module.exports = { | |||||
} | ||||||
``` | ||||||
|
||||||
Now you can access `process.env.customKey` in your code. For example: | ||||||
이제 코드에서 `process.env.customKey`에 접근할 수 있습니다. 예시를 보세요. | ||||||
|
||||||
```jsx | ||||||
function Page() { | ||||||
|
@@ -34,15 +34,15 @@ function Page() { | |||||
export default Page | ||||||
``` | ||||||
|
||||||
Next.js will replace `process.env.customKey` with `'my-value'` at build time. Trying to destructure `process.env` variables won't work due to the nature of webpack [DefinePlugin](https://webpack.js.org/plugins/define-plugin/). | ||||||
Next.js는 빌드 시에 `process.env.customKey`를 `'my-value'`로 대체할 것입니다. webpack [DefinePlugin]https://webpack.js.org/plugins/define-plugin/)의 특성 때문에 `process.env` 변수를 구조 분해하는 것은 작동하지 않습니다. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
For example, the following line: | ||||||
예를 들어 다음과 같은 줄. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```jsx | ||||||
return <h1>The value of customKey is: {process.env.customKey}</h1> | ||||||
``` | ||||||
|
||||||
Will end up being: | ||||||
다음과 같이 변환될 것입니다. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```jsx | ||||||
return <h1>The value of customKey is: {'my-value'}</h1> | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.