iconDirEasy
Configuration

Environment Variables

How to handle environment variables in DirEasy.

DirEasy has a composable environment variable system that allows you to define and validate environment variables in a type-safe way.

Overview

Type safety is provided by @t3-oss/env-nextjs, which provides runtime validation and autocompletion for all environment variables, located in the env.ts file.

Environment variable files

Here are the values you must fill in for the environment variable file:

.env
# Database
DATABASE_URL=
 
NEXT_PUBLIC_URL=
 
# Better Auth Authentication
BETTER_AUTH_URL=
BETTER_AUTH_SECRET=
 
# Payments
NEXT_PUBLIC_DEFAULT_PAYMENT_PROVIDER=
NEXT_PUBLIC_PREMIUM_PAYMENT_PRICE_ID=
NEXT_PUBLIC_PREMIUM_PLUS_PAYMENT_PRICE_ID=
NEXT_PUBLIC_SEO_ARTICLE_PRICE_PAYMENT_PRICE_ID=
 
# Email
EMAIL_PROVIDER=
## This is the mail address that users will use to contact you.
NEXT_PUBLIC_CONTACT_EMAIL=
## This is the mail address that will be used as the sender of all mails.
EMAIL_FROM=
 
# Cron
## This is the API key of your cron job. You can generate one using `openssl rand -hex 32` or use a complex random string.
CRON_API_KEY=
 
# Uploadthing
NEXT_PUBLIC_UPLOADTHING_URL=
UPLOADTHING_TOKEN=
  • For NEXT_PUBLIC_URL you should not modify them locally, but please replace them with the URL of your applications on the depoyment provider environment when you deploy them.

  • For payments and email, we support a few different providers. For more information, see the Payments and Email chapters.

  • For each environment variable, there is a detailed description in the .env.example file, as well as in the corresponding section in the documentation.

Adding an environment variable

To add a new environment variable, you need to do two things:

  1. Add the variable to each of the .env files across the project
  2. Add the variable to the server or client object in the env.ts file.

On this page