React .env 사용하기

JeongJaeSoon·2020년 12월 27일
0

front-end

목록 보기
1/1
post-thumbnail

React 에서 create-react-app 으로 프로젝트 생성 시, .env 파일에 REACT_APP 을 앞에 붙에서 환경 변수를 만들 수 있다.

참고자료 : https://create-react-app.dev/docs/adding-custom-environment-variables/

.env 파일 생성

  • root 파일에 .env 파일을 생성

.env 선언 방법

  • 다음과 같이 REACT_APP 을 앞에 붙여 변수를 선언하면 된다.
  • .env 파일은 수정 시, 꼭 다시 npm start 를 해주어야 한다.
REACT_APP_GOOGLE_MAP_KEY=...
profile
Just Keep Coding... 🧑🏻‍💻

0개의 댓글