Better Auth Next JS Cloudflare, D1 Example

Better auth example with next js, cf, d1. Implements

  • Magic Link
  • Social Sign-On
  • Passkey
  • Session & Account Management

Guide

  1. Install
pnpm install
  1. Create D1 Database
npx wrangler d1 create my_database    
  1. Add the binding to wrangler.toml

  2. Run the migration

npx wrangler d1 migrations apply my_database --local
  1. Fill environment variables (see .dev.vars.example)

  2. Run

pnpm dev