Skip to content
/ nuxthub-better-auth Public template

A demo of using Better Auth with Nuxt & NuxtHub (Cloudflare D1 & KV).

Notifications You must be signed in to change notification settings

atinux/nuxthub-better-auth

Repository files navigation

NuxtHub x BetterAuth

A demo of using BetterAuth with NuxtHub (Cloudflare Pages with D1 & KV).

https://better-auth.nuxt.dev

Deploy to NuxtHub

Features

  • Server-Side rendering on Cloudflare Workers
  • SQL Database on the edge
  • Use Key Value Storage as secondary storage for sessions, etc.
  • useAuth() Vue composable for easy authentication
  • serverAuth() composable for accessing Better Auth instance on the server
  • One click deploy on 275+ locations for free

Setup

Make sure to install the dependencies with pnpm:

pnpm install

Copy the .env.example file to .env and update the variables with your own values.

The BETTER_AUTH_SECRET should be a random string of your choosing used by Better Auth for encryption and generating hashes.

The GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET should be your GitHub OAuth application credentials (see create an OAuth application).

The NUXT_UI_PRO_LICENSE should be your Nuxt UI Pro license key (only required for production), if you don't have one, you can purchase one here.

Development Server

Start the development server on http://localhost:3000:

pnpm dev

Production

Build the application for production:

pnpm build

Deploy

Deploy the application on the Edge with NuxtHub on your Cloudflare account:

npx nuxthub deploy

Then checkout your server logs, analaytics and more in the NuxtHub Admin.

You can also deploy using Cloudflare Pages CI.

Database Migrations

Right now, we don't automatically run migrations on deployment. You can manually run them by visiting the /api/migrate endpoint after deploying.

About

A demo of using Better Auth with Nuxt & NuxtHub (Cloudflare D1 & KV).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •