Docs
Getting Started

Quickstart

Get started in about 30 minutes by following these steps.

Pre-requisites

Make sure you have the following installed on your machine.

Installation

  1. Unpack the archive

  2. Switch to the project's root directory:

Terminal
cd monorepo-next-drizzle-authjs
  1. Install the package dependencies for the whole monorepo:
Terminal
pnpm i

Environment variables

Copy the sample configurations:

Terminal
cp apps/dashboard/.env.example apps/dashboard/.envcp apps/marketing/.env.example apps/marketing/.envcp apps/public-api/.env.example apps/public-api/.envcp packages/database/.env.example packages/database/.env

Database

PostgreSQL

  1. Install PostgreSQL via Homebrew, Chocolatey or download it from the website:
Terminal
brew install postgresql
  1. Add an initial user:
Terminal
sudo -u postgres psqlCREATE USER postgres WITH PASSWORD 'password';ALTER USER postgres WITH SUPERUSER;\q

Connection string

  1. Update database packages/database/.env with your credentials:
packages/database/.env
DATABASE_URL=postgresql://postgres:password@localhost:5432/database?schema=public
  1. Apply the database migrations:
Terminal
pnpm --filter database migrate dev
  1. Update also the dashboard apps/dashboard/.env with your credentials.
apps/dashboard/.env
DATABASE_URL=postgresql://postgres:password@localhost:5432/database?schema=public

Authentication

Auth secret

Technically you can skip this step, but we recommend to generate a new AUTH_SECRET in apps/dashboard/.env.

For this simply run:

Terminal
npx auth secret

or alternatively you can run:

Terminal
openssl rand -base64 32

Google login (optional)

  1. Visit the Google Cloud Console.
  2. Create an account if you don't have one already.
  3. Navigate to APIs or click here
  4. Configure the OAuth consent screen and add yourself as test user.
  5. Click on Credentials, create new OAuth credentials and save those credentials.
  6. Add the Authorized JavaScript origin to the credential settings:
http://localhost:3000
  1. Add the Authorized redirect URI to the credential settings:
http://localhost:3000/api/auth/callback/google
  1. Update apps/dashboard/.env with the created credentials:
apps/dashboard/.env
AUTH_GOOGLE_CLIENT_ID=AUTH_GOOGLE_CLIENT_SECRET=

Microsoft login (optional)

  1. Visit the Azure Portal.
  2. Create an account if you don't have one already.
  3. Navigate to your Entra ID (Active Directory).
  4. Register a new application with platform web.
  5. Click on Authentication in the menu and add the redirect URIs
http://localhost:3000http://localhost:3000/api/auth/callback/microsoft-entra-id
  1. Under Certificates & Secrets, create a new client secret.
  2. Update apps/dashboard/.env with the created secret:
apps/dashboard/.env
AUTH_MICROSOFT_ENTRA_ID_CLIENT_ID=AUTH_MICROSOFT_ENTRA_ID_CLIENT_SECRET=

Billing

Stripe

  1. Visit the Stripe Dashboard.
  2. Create an account if you don't have one already.
  3. Activate test mode.
  4. Activate the customer billing portal.
  5. Create a product.
  6. Create a price for the product.
  7. Navigate to developer section and copy the API credentials.
  8. Update apps/dashboard/.env with the IDs and credentials:
apps/dashboard/.env
NEXT_PUBLIC_BILLING_STRIPE_PUBLISHABLE_KEY=BILLING_STRIPE_SECRET_KEY=BILLING_PRO_PRODUCT_ID=BILLING_PRO_PRODUCT_PRICE_ID=

Billing unit

You can specify the billing unit as per_seat or per_organization. The difference is that per seat you bill for every user in the organization and per_organization you bill for the whole organization regardless of user seats.

apps/dashboard/.env
BILLING_UNIT=per_seat # per_seat | per_organization

We recommend to leave it at per_seat if you are not sure.

Webhook

To receive webhooks you can either use the Stripe CLI or ngrok. Let's say you use ngrok. Start ngrok, then go to Developers -> Webhooks and create a new webhook. Enter your ngrok URL + /api/stripe/webhook:

https://randomsubdomain.ngrok-free.app/api/stripe/webhook

Open your newly created webhook and on the right side is your Signing secret. Press reveal and copy the secret, then update apps/dashboard/.env with the secret:

apps/dashboard/.env
BILLING_STRIPE_WEBHOOK_SECRET=

Emails

Mailer

The starter kit supports Nodemailer (SMTP) and Resend.

  1. Choose an SMTP provider in packages/email/provider/index.ts.
  2. Update apps/dashboard/.env with SMTP credentials.
apps/dashboard/.env
EMAIL_FROM=# NodemailerEMAIL_NODEMAILER_URL=# ResendEMAIL_RESEND_API_KEY=

For Gmail you need an app-specific password and set it up like the following URL:

apps/dashboard/.env
EMAIL_NODEMAILER_URL='smtp://myemail@gmail.com:suyz yeba qtgv xrnp@smtp.gmail.com:465'

Applications

Dashboard application

To only start the dashboard application, run:

Terminal
pnpm --filter dashboard dev

Marketing application

To only start the marketing application, run:

Terminal
pnpm --filter marketing dev

All applications

To start all applications under apps, run the command:

Terminal
pnpm run dev

Preferred command if your machine can handle it. All apps will run in parallel. Note that in the Turborepo task UI there is no way to set an order yet, but you can navigate with the up/down arrow keys.