-
Notifications
You must be signed in to change notification settings - Fork 205
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 (수정) #418
Merged
Merged
Changes from 1 commit
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 | ||||
---|---|---|---|---|---|---|
|
@@ -2,48 +2,3 @@ | |||||
title: 환경 변수 | ||||||
description: 빌드 시 Next.js 애플리케이션에서 환경 변수를 추가하고 액세스하는 방법을 알아보세요. | ||||||
--- | ||||||
|
||||||
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
아래 내용 추가해주세요! 주석 부분도 지우시면 안 됩니다. |
||||||
> [Next.js 9.4](https://nextjs.org/blog/next-9-4)의 출시 이후로 [환경 변수 추가하기](/docs/pages/building-your-application/configuring/environment-variables)가 더 직관적이고 사용하기 쉽습니다. 한번 시도해 보세요! | ||||||
|
||||||
<details> | ||||||
<summary>예제</summary> | ||||||
|
||||||
- [env 활용하기](https://github.com/vercel/next.js/tree/canary/examples/with-env-from-next-config-js) | ||||||
|
||||||
</details> | ||||||
|
||||||
> **참고**. 이런 방식으로 지정된 환경 변수들은 **항상** 자바스크립트 번들에 포함됩니다. 환경 변수 이름 앞에 `NEXT_PUBLIC_`를 붙이는 것은 환경 변수들을 [환경 또는 .env 파일을 통해](/docs/pages/building-your-application/configuring/environment-variables) 지정할 때만 효과가 있습니다. | ||||||
|
||||||
자바스크립트 번들에 환경 변수를 추가하려면 `next.config.js`를 열고 `env` 설정을 추가하세요. | ||||||
|
||||||
```js filename="next.config.js" | ||||||
module.exports = { | ||||||
env: { | ||||||
customKey: 'my-value', | ||||||
}, | ||||||
} | ||||||
``` | ||||||
|
||||||
이제 코드에서 `process.env.customKey`에 접근할 수 있습니다. 예시를 보세요. | ||||||
|
||||||
```jsx | ||||||
function Page() { | ||||||
return <h1>The value of customKey is: {process.env.customKey}</h1> | ||||||
} | ||||||
|
||||||
export default Page | ||||||
``` | ||||||
|
||||||
Next.js는 빌드 시에 `process.env.customKey`를 `'my-value'`로 대체할 것입니다. 웹팩 [DefinePlugin](https://webpack.js.org/plugins/define-plugin/)의 특성 때문에 `process.env` 변수는 구조 분해할 수 없습니다. | ||||||
|
||||||
예를 들어 다음과 같은 줄은, | ||||||
|
||||||
```jsx | ||||||
return <h1>The value of customKey is: {process.env.customKey}</h1> | ||||||
``` | ||||||
|
||||||
아래와 같이 변환될 것입니다. | ||||||
|
||||||
```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.
source 부분 추가해주세요! pages 문서는 app 문서 내용을 바라보기 때문에 source 빼먹으시면 안 됩니다.