/nextjs_drizzle_better-auth

A Next.js starter kit integrating Drizzle ORM for type-safe database operations, Better Auth for secure authentication, and NeonDB for serverless PostgreSQL. This template offers a robust, scalable foundation for building modern full-stack applications with TypeScript and a cloud-native database.

Primary LanguageTypeScript

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the install:

pnpm install

Adding the env credentials

DATABASE_URL= #Your Neon DB URL
BETTER_AUTH_SECRET= #Your Better Auth Secret
BETTER_AUTH_URL=http://localhost:3000 #Your Base URL of your app
GOOGLE_CLIENT_ID= #Your Google Client ID
GOOGLE_CLIENT_SECRET= #Your Google Client Secret
GITHUB_CLIENT_ID= #Your Github Client ID
GITHUB_CLIENT_SECRET= #Your Github Client Secret
RESEND_API_KEY= #Your Resend API Key

Running the Better auth cli to get our schema for drizzle

It will generate a auth-schema.ts that we need to copy to the drizzle schema

    npx @better-auth/cli generate

We need to copy the content of the auth-schema to the drizzle schema in the db folder.

Pussing the schema to the Neon db

first we need to generate the schema

    npx db:generate

after that we need to push it to our Neon db

    npx db:push

Starting the application

Now if we have done everything correct we can visit it on localhost:3000

pnpm run dev