Skip to content

Environment Variables

For StudioCMS to work correctly, you must set up the correct environment variables. These variables are essential for establishing a secure connection to Astro DB and authenticating with the StudioCMS API. Without correctly configuring these environment variables, the application will not function as intended.

You can create a .env file in the root directory of your project and add the required environment variables. The .env file is a text file that contains key-value pairs of environment variables. The environment variables are read by the application at runtime.

For future reference on how to work with environment variables within Astro you can checkout Environment Variables from the Astro documentation.

Required Environment Variables

If using Astro’s Studio with @astrojs/db

Astro Studio Account Required

ASTRO_STUDIO_APP_TOKEN - Token provided from the Astro Studio Dashboard

.env
ASTRO_STUDIO_APP_TOKEN=your_app_token

If using libSQL with @astrojs/db

ASTRO_DB_REMOTE_URL - The connection URL to your libSQL server ASTRO_DB_APP_TOKEN - The app token for your libSQL server

.env
ASTRO_DB_REMOTE_URL=file://local-copy.db?encryptionKey=your-encryption-key&syncInterval=60&syncUrl=libsql%3A%2F%2Fyour.server.io
ASTRO_DB_APP_TOKEN=token-to-your-remote-url

Authentication Environment Variables

Currently there are 5 ways to authenticate with StudioCMS:

GitHub

To authenticate with GitHub, you need to add the following environment variables to your .env file:

.env
# credentials for GitHub OAuth
# Callback URL for github (NOT AN ENV VARIABLE): 'http://localhost:4321/dashboard/login/github/callback'
CMS_GITHUB_CLIENT_ID=your_client_id
CMS_GITHUB_CLIENT_SECRET=your_client_secret

Discord

.env
# credentials for Discord OAuth
CMS_DISCORD_CLIENT_ID=
CMS_DISCORD_CLIENT_SECRET=
CMS_DISCORD_REDIRECT_URI=http://localhost:4321/dashboard/login/discord/callback

Google

.env
# credentials for Google OAuth
CMS_GOOGLE_CLIENT_ID=
CMS_GOOGLE_CLIENT_SECRET=
CMS_GOOGLE_REDIRECT_URI=http://localhost:4321/dashboard/login/google/callback

Auth0

.env
# credentials for auth0 OAuth
CMS_AUTH0_CLIENT_ID=
CMS_AUTH0_CLIENT_SECRET=
CMS_AUTH0_DOMAIN=
CMS_AUTH0_REDIRECT_URI=http://localhost:4321/dashboard/login/auth0/callback

Username and Password

Alternatively, you can authenticate with StudioCMS using your username and password which doesn’t require any additional environment variables.

Image Handler Environment Variables

Cloudinary (Optional)

If you choose to use the built-in Cloudinary plugin, you will need to define the following:

.env
## Cloudinary Javascript SDK
CMS_CLOUDINARY_CLOUDNAME="demo"