Setup

Setup largely revolves around adding the required values to env variables in the .env file. Getting these values requires some steps.

Running the app

Running the app only requires adding values for all the variables in the .env file.

Then simply run npm run dev

If using email login and maildev run npm run maildev

Thats it to run the app.

npx prisma studio can be used for local development database work as well.

Create Dev Postgres

Creating a local DB will be the first step to setting up the project.

Simply follow Postgres excellent documentation on setting up Postgres and PgAdmin4 on your own local machine.

Once you have PgAdmin setup, you can use it to create a database with a simple CREATE DATABASE db_name command.

Once done, simply add the database connection URL with your credentials you setup into the DATABASE_URL= variable in the .env file.

Setup Test Database

It is possible to use the same db for both test and local dev. In order to avoid flakiness it might be helpful to have a dedicated test db. Simply create a test db using a CREATE DATABASE test_db command and substitute the connection URL to the DATABASE_URL_TEST= env variable in the .env file.

The database will only need to be created once, Playwright will clear the db after every run.

Setup Auth

There are several Steps to setting up the Authentication functionality.

Google Oauth

Setting up Google oauth is not strictly necessary to run the app in development. You can simply use email auth if you would like to jump right into development.

Google oauth can be removed entirely and other social logins can be used.

Google Oauth will generally need to be setup before prod deployment.

See more info about Google Oauth setup here:

https://www.telerik.com/blogs/how-to-implement-google-authentication-nextjs-app-using-nextauth (opens in a new tab)

Working with Emails

Detailed information on working with emails can be found in the Auth/Emails docs section.

Setting up Subscriptions

This project allows using either Lemon Squeezy or Stripe.

See payments section for more info.

Commands

"dev": nextjs command to run the app in dev

"build": nextjs command to build the files for prod deployment

"start:" nextjs command to run the output build files

"lint": run linting

"postinstall": runs in vercel CI/CD. Used to populate the db and update the prisma client.

"maildev": runs mail dev, only used in development and testing envs.

"test": runs tests in headless mode

"test:ui": runs tests in UI mode

"stripe:listen": running stripe cli

"ngrok": used to add a public url during local dev, can be used to test the full subscription flow


⚠️ Stripe Cli is generally not a good way to test the webhook in dev. Its better to use ngrok and substitute the ngrok URL for the webhook endpoint in the stripe dashboard. This will allow you to go through stripe checkout and run the full subscription flow.