So we just moved from CRA to Vite for our React app. In CRA we used the .env file to get the Netlify environment variables into React.
CRA .env file:
# get the Netlify environment variables REACT_APP_COMMIT_REF=$COMMIT_REF REACT_APP_PULL_REQUEST=$PULL_REQUEST REACT_APP_REVIEW_ID=$REVIEW_ID
When we did this I could then access these variables in our React code with
Now I have moved to Vite and updated the .env file to:
# get the Netlify environment variables VITE_COMMIT_REF=$COMMIT_REF VITE_PULL_REQUEST=$PULL_REQUEST VITE_REVIEW_ID=$REVIEW_ID
I try to use them with
but it’s undefined.
Does anyone know how to properly hook this up in a Vite/React app?