Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atinux/nuxthub-better-auth
A demo of using Better Auth with Nuxt & NuxtHub (Cloudflare D1 & KV).
https://github.com/atinux/nuxthub-better-auth
better-auth cloudflare d1 nuxt nuxthub vue
Last synced: 5 days ago
JSON representation
A demo of using Better Auth with Nuxt & NuxtHub (Cloudflare D1 & KV).
- Host: GitHub
- URL: https://github.com/atinux/nuxthub-better-auth
- Owner: atinux
- Created: 2024-10-23T13:04:15.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-12-23T10:53:43.000Z (about 1 month ago)
- Last Synced: 2025-01-17T01:00:06.825Z (12 days ago)
- Topics: better-auth, cloudflare, d1, nuxt, nuxthub, vue
- Language: TypeScript
- Homepage: https://better-auth.nuxt.dev
- Size: 688 KB
- Stars: 72
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NuxtHub x BetterAuth
A demo of using [BetterAuth](https://better-auth.com) with [NuxtHub](https://hub.nuxt.com) (Cloudflare Pages with D1 & KV).
https://better-auth.nuxt.dev
[![Deploy to NuxtHub](https://hub.nuxt.com/button.svg)](https://admin.hub.nuxt.com/new?repo=atinux/nuxthub-better-auth)
## Features
- Server-Side rendering on Cloudflare Workers
- [SQL Database](https://hub.nuxt.com/docs/features/database) on the edge
- Use [Key Value Storage](https://hub.nuxt.com/docs/features/kv) 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](https://pnpm.io/installation#using-corepack):
```bash
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](https://github.com/settings/applications/new)).
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](https://ui.nuxt.com/pro).
## Development Server
Start the development server on `http://localhost:3000`:
```bash
pnpm dev
```## Production
Build the application for production:
```bash
pnpm build
```## Deploy
Deploy the application on the Edge with [NuxtHub](https://hub.nuxt.com) on your Cloudflare account:
```bash
npx nuxthub deploy
```Then checkout your server logs, analaytics and more in the [NuxtHub Admin](https://admin.hub.nuxt.com).
You can also deploy using [Cloudflare Pages CI](https://hub.nuxt.com/docs/getting-started/deploy#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.