Docs
Skip to content

Sites

Environment variables_

Set environment variables for your Appwrite Sites to pass constants and secrets at build and runtime.

3 min read

Raw

Appwrite Sites can read environment variables at build and runtime. Use them to pass constants and secrets such as API keys, connection strings, and feature flags without hardcoding them in your source.

A site reads from three sources, in this order of precedence:

  1. Project variables are shared across every function and site in your project. Set them once and every site inherits them automatically. See project variables for the full reference.
  2. Site variables are scoped to a single site. Override a project variable for one site by setting the same key on the site itself.
  3. Appwrite-injected variables are set by Appwrite at deployment time (for example, APPWRITE_SITE_PROJECT_ID). These take final precedence and cannot be overridden.

Manage in the Console

  1. Navigate to your site in the Appwrite Console.
  2. Open the Settings tab > Environment variables section.
  3. Click Create variable and enter a key and value.
  4. Optionally select the Secret checkbox to prevent any team member from reading the value after creation.
  5. Click Create, then redeploy the site for the change to take effect.

Site environment variables
Site environment variables

You can also configure global variables that apply to all your sites from your project's Settings page. See project variables for details.

Manage with a Server SDK

You can also manage site variables programmatically using a Server SDK. Each call requires an API key with the sites.write scope to create, update, or delete variables, or the sites.read scope to list and read them.

Create a variable

List variables

Get a variable

Update a variable

You can change a variable's key, value, or secret flag. Marking a variable as secret is one-way. Once set, the value is no longer readable from the Console or API.

Delete a variable

Read variables in your site

Read variables inside your site using your framework's standard environment lookup. For SSR sites, variables are read at runtime; for static sites, variables marked for build are inlined at build time.

For framework-specific guidance such as Next.js, SvelteKit, or Astro, see the framework adapters.

Appwrite-injected variables

Appwrite passes the following environment variables into every site deployment by default. They take precedence over your own variables, so do not set keys with the APPWRITE_ prefix.

VariableDescriptionAvailable at Build and/or Run Time
APPWRITE_SITE_API_ENDPOINTThe API endpoint of the running siteBoth
APPWRITE_VERSIONThe Appwrite version used to run the siteBoth
APPWRITE_REGIONThe region where the site will run fromBoth
APPWRITE_DEPLOYMENT_TYPEThe deployment source type, such as manual, cli, or vcsBoth
APPWRITE_SITE_API_KEYThe site API key used for server authenticationBuild time
APPWRITE_SITE_IDThe ID of the running siteBoth
APPWRITE_SITE_NAMEThe name of the running siteBoth
APPWRITE_SITE_DEPLOYMENTThe deployment ID of the running siteBoth
APPWRITE_SITE_PROJECT_IDThe project ID of the running siteBoth
APPWRITE_SITE_RUNTIME_NAMEThe runtime name of the running siteBoth
APPWRITE_SITE_RUNTIME_VERSIONThe runtime version of the running siteBoth
APPWRITE_SITE_CPUSThe CPU (runtime) specification of the running siteBoth
APPWRITE_SITE_MEMORYThe memory (runtime) specification of the running siteBoth
APPWRITE_VCS_REPOSITORY_IDThe provider repository ID for VCS deploymentsBoth
APPWRITE_VCS_REPOSITORY_NAMEThe provider repository name for VCS deploymentsBoth
APPWRITE_VCS_REPOSITORY_OWNERThe owner of the provider repositoryBoth
APPWRITE_VCS_REPOSITORY_URLThe URL of the provider repositoryBoth
APPWRITE_VCS_REPOSITORY_BRANCHThe branch used for the VCS deploymentBoth
APPWRITE_VCS_REPOSITORY_BRANCH_URLThe URL of the branch used for the VCS deploymentBoth
APPWRITE_VCS_COMMIT_HASHThe commit hash used for the VCS deploymentBoth
APPWRITE_VCS_COMMIT_MESSAGEThe commit message used for the VCS deploymentBoth
APPWRITE_VCS_COMMIT_URLThe URL of the commit used for the VCS deploymentBoth
APPWRITE_VCS_COMMIT_AUTHOR_NAMEThe name of the VCS commit authorBoth
APPWRITE_VCS_COMMIT_AUTHOR_URLThe URL of the VCS commit authorBoth
APPWRITE_VCS_ROOT_DIRECTORYThe root directory configured for the VCS deploymentBoth

VCS metadata variables are populated for Git deployments. For manual and CLI deployments, VCS fields may be empty.

Secret variables

Mark a variable as Secret to hide its value from the Console and API after creation. Only the site runtime can read the value at build and runtime. Team members and external integrations cannot retrieve it after creation.

You can mark a variable as secret either when you create it or by updating an existing variable. Marking a variable as secret cannot be reversed. To replace a secret value, delete the variable and create a new one with the same key.

Limits

FieldLimit
Variable ID36 characters, a-z A-Z 0-9 . - _
Key255 characters
Value8192 characters

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.