Skip to content

simonweniger/nusoma

Repository files navigation

Introduction

Next 16 starter kit based on Next.js, Auth.js and Drizzle designed to accelerate the development of web-based (SaaS) applications.

Quickstart

Get started in about 30 minutes by following these steps.

Preparation

  1. Unpack the Archive

  2. Switch to the project's root directory

cd monorepo-next-drizzle-authjs
  1. Install Bun if not already installed (See https://bun.sh/ for instructions)

  2. Install the package dependencies of the whole monorepo

bun install
  1. Copy the sample configurations
cp apps/dashboard/.env.example apps/dashboard/.env
cp apps/marketing/.env.example apps/marketing/.env
cp apps/public-api/.env.example apps/public-api/.env
cp packages/database/.env.example packages/database/.env

Services

Database

Install PostgreSQL

  1. Install PostgreSQL via Homebrew, Chocolatey or download it from the website.
brew install postgresql
  1. Add an initial user.
sudo -u postgres psql
CREATE USER postgres WITH PASSWORD 'password';
ALTER USER postgres WITH SUPERUSER;
\q
  1. Update database packages/database/.env with your credentials.
DATABASE_URL=postgresql://postgres:password@localhost:5432/database?schema=public
  1. Create the database
psql -U postgres -c "CREATE DATABASE database;"
  1. Apply the database migrations.
bun run --filter database push
  1. Update also the dashboard apps/dashboard/.env with your credentials.
DATABASE_URL=postgresql://postgres:password@localhost:5432/database?schema=public

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 dashboard apps/dashboard/.env with the created credentials.
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:3000
http://localhost:3000/api/auth/callback/microsoft-entra-id
  1. Under Certificates & Secrets, create a new client secret.
  2. Update dashboard apps/dashboard/.env with the created secret.
AUTH_MICROSOFT_ENTRA_ID_CLIENT_ID=
AUTH_MICROSOFT_ENTRA_ID_CLIENT_SECRET=

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 dashboard apps/dashboard/.env with the IDs and credentials.
NEXT_PUBLIC_BILLING_PRICE_PRO_MONTH_ID=
NEXT_PUBLIC_BILLING_PRICE_PRO_YEAR_ID=
NEXT_PUBLIC_BILLING_PRICE_LIFETIME_ID=
NEXT_PUBLIC_BILLING_PRICE_ENTERPRISE_MONTH_ID=
NEXT_PUBLIC_BILLING_PRICE_ENTERPRISE_YEAR_ID=
BILLING_STRIPE_SECRET_KEY=
BILLING_STRIPE_WEBHOOK_SECRET=

SMTP Provider

The starter kit supports Nodemailer (SMTP) and Resend.

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

# Provider: NodeMailer

EMAIL_NODEMAILER_URL=

# Provider: Postmark
EMAIL_POSTMARK_SERVER_TOKEN=

# Provider: Resend
EMAIL_RESEND_API_KEY=

# Provider: SendGrid
EMAIL_SENDGRID_API_KEY=

For Gmail you need an app-specific password and set it up like this

EMAIL_NODEMAILER_URL=smtp://myemail@gmail.com:suyz yeba qtgv xrnp@smtp.gmail.com:465

We recommend Resend for the ease of use.

SMTP provider is mandatory for credentials login.

Dashboard Application

  1. Start the dashboard application
bun run --filter dashboard dev
  1. Navigate to http://localhost:3000

You’re all set to start!

Marketing Application

  1. Start the marketing application
bun run --filter marketing dev
  1. Navigate to http://localhost:3001

You’re all set to start!

Public API Application

  1. Start the public API application
bun run --filter public-api dev
  1. Navigate to http://localhost:3002

You’re all set to start!

Troubleshoot

It seems that I can't login

The database is probably not set up.

NPM throws an error

In the monorepo version npm is no longer supported. It's all Bun now. The problem is that npm, yarn and pnpm have different workspace syntax and package hoisting patterns. Supporting all package managers is not possible in a monorepo setup and Bun is the fastest one.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages