theotarr / next-auth-microservice

Example of Next Auth being used in a monorepo (turborepo) as a microservice.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Next Auth As A Microservice

This is an example of how to use Next Auth as a microservice and inside a monorepo. Basically I've built a custom backend Express wrapper of Next Auth that handles authentication and any other things you may need.

I've written a blog post about this that goes into the story and reasons why I chose to expiriment with this approach.

Setup

First, create a .env file in the root of the monorepo, copy and paste the .env.example and fill in the fields with the proper credentials.

Second, navigate to the prisma package (./packages/prisma) and create a .env file with only your DATABASE_URL inside. (Prisma only looks to the root of the prisma package for the .env file)

Tech Stack

Front-end:

  • Next.js for the web app (next-app)
  • Tailwind CSS for styling

Back-end:

  • Express.js for the server
  • Next-Auth.js for authentication
  • Prisma with a PostgreSQL database for storing data

Utilities

This turborepo has some additional tools already setup for you:

Build

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

cd next-auth-microservice
yarn run build

Develop

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

cd next-auth-microservice
yarn run dev

About

Example of Next Auth being used in a monorepo (turborepo) as a microservice.


Languages

Language:TypeScript 65.8%Language:JavaScript 33.7%Language:CSS 0.5%