#Checking if in dev or prod env
3 messages · Page 1 of 1 (latest)
Hi @naive kite. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To check whether you are in development or production environment in Astro, you can use the default environment variables provided by Astro. Here's how you can do it:
const isProd = import.meta.env.PROD;
const isDev = import.meta.env.DEV;
These environment variables are boolean values:
import.meta.env.PROD:trueif your site is running in production;falseotherwise.import.meta.env.DEV:trueif your site is running in development;falseotherwise. This is always the opposite ofimport.meta.env.PROD.
You can use these variables in your Astro components or scripts to conditionally execute code based on the environment.