You are trying to retrieve a variable that doesn't exist in the .env file.
import.meta.env.BEARER_TOKEN instead of import.meta.env.VITE_BEARER_TOKEN
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am simply trying to load a tweet and there is a variable called bearer_token that you need in order to get a json object with stuff for tweets. I am trying to store it in a .env file. I stored it in .env.local but it is not pulling the variable.
What should I do? Here is the documentation for using .env in Vitejs .env file
BEARER_TOKEN="MYLONGBORINGRANDOMPASSWORD"
Now, App.vue
<script setup>
const BEARER_TOKEN = import.meta.env.VITE_BEARER_TOKEN;
console.log(BEARER_TOKEN);
</script>
But, it is not working.
Please or to participate in this conversation.