Skip to content

Misleading Cloudflare environment variables section #13897

@alexanderdombroski

Description

@alexanderdombroski

📚 Subject area/topic

Cloudflare Environment Variables

📋 Page(s) affected (or suggested, for new content)

Page: https://docs.astro.build/en/guides/integrations-guide/cloudflare/#environment-variables-and-bindings
Filepath: src/content/docs/en/guides/integrations-guide/cloudflare.mdx

📋 Description of content that is out-of-date or incorrect

Background

When using the Cloudflare adapter, I've learned I can use environment variables in 4 ways.

  1. using import.meta.env.*
  2. using imports from "astro:env/client" or "astro:env/server"
  3. using the env object imported from "cloudflare:workers"
  4. using process.env.*

From my understanding, the first two are Astro's type-safe system and second two are Cloudflare's (also type-safe) system.

The Confusing Part

In the cloudflare adapter guide, the sentence "They are also compatible with the astro:env API" is unclear.

Cloudflare environment variables defined in .dev.vars, wrangler.jsonc or the cloudflare dashboard can NOT be imported from astro:env/server.

Is the documentation only suggesting that I can use both environment variable systems in the same application? Or is it that the APIs are connected and can be mixed? It should be clearly stated that these two systems are separate and when either is preferable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help - confirm behaviourWalk through the example/issue and confirm this is a general behaviour, or a correct update to make.improve or update documentationEnhance / update existing documentation (e.g. add example, improve description, update for changes)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions