Skip to contentView the source on GitHub

no-process-env

Disallow process.env in Astro files — use import.meta.env instead.

Best Practiceswarning by default ESLint rule

astro-doctor/no-process-env

Why it matters

process.env is a Node.js-specific API that does not work in client-side contexts. import.meta.env is Astro's standard for environment variables: it works in both server and client code, respects the PUBLIC_ prefix for client-safe exposure, and is type-safe with the Astro env schema.

See the difference

Incorrect

Using process.env

astroIncorrect example
---
const apiKey = process.env.API_KEY
const publicUrl = process.env.PUBLIC_SITE_URL
---
<p>{publicUrl}</p>

Correct

Using import.meta.env

astroCorrect example
---
const apiKey = import.meta.env.API_KEY
const publicUrl = import.meta.env.PUBLIC_SITE_URL
---
<p>{publicUrl}</p>

Configure this check

Override the default severity in your ESLint config:

javascripteslint.config.js
import astroDoctorPlugin from '@santi020k/eslint-plugin-astro-doctor'

export default [
  astroDoctorPlugin.configs.recommended,
  {
    rules: {
      'astro-doctor/no-process-env': 'error',
    },
  },
]

Or set the severity for CLI scans in doctor.config.ts:

typescriptdoctor.config.ts
export default {
  rules: {
    'astro-doctor/no-process-env': 'error',
  },
}

Use 'error', 'warn', or 'off'. The configuration guide covers presets and per-file overrides.

Keep exploring best practices

Browse every rule and project audit