Next.js Discord

Discord Forum

Tokens from `.env` are not loaded into `app` folder

Answered
Chinese softshell turtle posted this in #help-forum
Open in Discord
Chinese softshell turtleOP
I have project: https://github.com/kuskusapp/kuskus
I put my env variables in root .env
then i try log console.log(process.env.HUGGINGFACE_TOKEN, "token"), its undefined
Answered by Chinese softshell turtle
    useEffect(() => {
        console.log(process.env.NEXT_PUBLIC_HUGGINGFACE_TOKEN, "token")
    }, [])
View full answer

10 Replies

Chinese softshell turtleOP
is this how you do it with app folder?
none of these tokens are being read right now in root
my env is fully empty now
Chinese softshell turtleOP
tried to do this
still env is empty
Chinese softshell turtleOP
    useEffect(() => {
        console.log(process.env.NEXT_PUBLIC_HUGGINGFACE_TOKEN, "token")
    }, [])
Answer
Chinese softshell turtleOP
ok this works