iconDirEasy

Authentication

How to manage Sign in and Sign up in your DirEasy app.

DirEasy use BetterAuth to manage authentication. supports email/password, GitHub, and Google authentication.

For email login you don't need to have additional settings, if you want to enable other login methods, please follow the steps below to configure them.

Configuration

Generate the BETTER_AUTH_SECRET variable

BETTER_AUTH_SECRET is a random value, and you can generate one via running:

Terminal
npx auth secret
# or
openssl rand -base64 32

Then set it to the .env file.

.env
BETTER_AUTH_SECRET=

[Optional] Get the Google client variables

If you want to use Google as an OAuth provider, you need to update the GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET variables.

You can get the client_id and client_secret from the Google Cloud Console.

For the callback URL, it is https://your-domain.com/api/auth/callback/google or http://localhost:3000/api/auth/callback/google for local development.

.env
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# set to true to enable Google OAuth Login
NEXT_PUBLIC_ENABLE_GOOGLE_OAUTH=true

[Optional] Get the GitHub client variables

If you want to use GitHub as an OAuth provider, you need to update the GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET variables.

Follow the steps here to get the client_id and client_secret from the GitHub Developer Settings.

For the callback URL, it is https://your-domain.com/api/auth/callback/github or http://localhost:3000/api/auth/callback/github for local development.

.env
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
# set to true to enable GitHub OAuth Login
NEXT_PUBLIC_ENABLE_GITHUB_OAUTH=true

Please note that the environment variables are different in development and production environments, make sure to create two different OAuth applications for the production and development environments.

On this page