Skip to content

Denoder/next-auth-database-session

 
 

Repository files navigation

Nextjs + NextAuth + Prisma

This is nextjs + next-auth credentials with session example

Using this example

Run the following command:

git clone https://github.com/decovicdev/next-auth-database-session.git

What's inside?

This turborepo includes the following packages/apps:

Apps and Packages

  • app: a Next.js app (app directory)
  • pages: a Next.js app (pages directory)
  • config: eslint configurations (includes eslint-config-next and eslint-config-prettier)
  • validation: zod schemas to validate and parse user input
  • database: Prisma ORM wrapper to manage & access your database
  • tsconfig: tsconfig.jsons used throughout the monorepo

Each package/app is 100% TypeScript.

Utilities

This turborepo has some additional tools already setup for you:

Database

We use Prisma to manage & access our database. As such you will need a database for this project, either locally or hosted in the cloud.

To make this process easier, use docker-compose.yml file to deploy a PostgresSQL server locally with a new database named turborepo (To change this update the POSTGRES_DB environment variable in the docker-compose.yml file):

cd next-auth-database-session
docker-compose up -d

Once deployed you will need to copy the .env.example file to .env in order for Prisma to have a DATABASE_URL environment variable to access.

cp .env.example .env

If you added a custom database name, or use a cloud based database, you will need to update the DATABASE_URL in your .env accordingly.

Once deployed & up & running, you will need to create & deploy migrations to your database to add the necessary tables. This can be done using Prisma Migrate:

npx prisma migrate dev

If you need to push any existing migrations to the database, you can use either the Prisma db push or the Prisma migrate deploy command(s):

pnpm run db:push

# OR

pnpm run db:migrate:deploy

For further more information on migrations, seeding & more, we recommend reading through the Prisma Documentation.

Build

To build all apps and packages, run the following command:

pnpm run build

Develop

To develop all apps and packages, run the following command:

pnpm run dev

Useful Links

Learn more about the power of Turborepo:

About

monorepo: nextauth pages and app dir with multiple providers example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.8%
  • CSS 1.2%
  • JavaScript 1.0%