A demo of using BetterAuth with NuxtHub (Cloudflare Pages with D1 & KV).
- 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 authenticationserverAuth()composable for accessing Better Auth instance on the server- One click deploy on 275+ locations for free
Make sure to install the dependencies with pnpm:
pnpm installCopy 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.
Start the development server on http://localhost:3000:
pnpm devBuild the application for production:
pnpm buildDeploy the application on the Edge with NuxtHub on your Cloudflare account:
npx nuxthub deployThen checkout your server logs, analaytics and more in the NuxtHub Admin.
You can also deploy using Cloudflare Pages CI.
Right now, we don't automatically run migrations on deployment. You can manually run them by visiting the /api/migrate endpoint after deploying.