feat: add clerk auth support with convex (#548)

This commit is contained in:
Aman Varshney
2025-08-29 00:21:08 +05:30
committed by GitHub
parent 8d48ae0359
commit 54bcdf1cbc
153 changed files with 1954 additions and 771 deletions

View File

@@ -59,7 +59,7 @@ create-better-t-stack --runtime workers --backend hono --database sqlite --orm d
#### Convex Backend
When using `--backend convex`, the following options are automatically set:
- `--auth false` (Convex handles auth)
- `--auth clerk` (if compatible frontends selected, otherwise `none`)
- `--database none` (Convex provides database)
- `--orm none` (Convex provides data layer)
- `--api none` (Convex provides API)
@@ -67,10 +67,12 @@ When using `--backend convex`, the following options are automatically set:
- `--db-setup none` (Convex manages hosting)
- `--examples todo` (Todo example works with Convex)
**Note:** Convex supports Clerk authentication with compatible frontends (React frameworks, Next.js, TanStack Start, and native frameworks). Nuxt, Svelte, and Solid are not compatible with Clerk.
#### No Backend
When using `--backend none`, the following options are automatically set:
- `--auth false` (No backend for auth)
- `--auth none` (No backend for auth)
- `--database none` (No backend for database)
- `--orm none` (No database)
- `--api none` (No backend for API)
@@ -158,17 +160,30 @@ create-better-t-stack --frontend next native-nativewind
## Authentication Requirements
Authentication requires:
### Better-Auth Requirements
Better-Auth authentication requires:
- A backend framework (cannot be `none`)
- A database (cannot be `none`)
- An ORM (cannot be `none`)
```bash
# ❌ Invalid - Auth without database
create-better-t-stack --auth --database none
### Clerk Requirements
Clerk authentication requires:
- Convex backend (`--backend convex`)
- Compatible frontends (React frameworks, Next.js, TanStack Start, native frameworks)
- Not compatible with Nuxt, Svelte, or Solid
# ✅ Valid - Auth with full stack
create-better-t-stack --auth --database postgres --orm drizzle --backend hono
```bash
# ❌ Invalid - Better-Auth without database
create-better-t-stack --auth better-auth --database none
# ✅ Valid - Better-Auth with full stack
create-better-t-stack --auth better-auth --database postgres --orm drizzle --backend hono
# ✅ Valid - Clerk with Convex
create-better-t-stack --auth clerk --backend convex --frontend tanstack-router
# ❌ Invalid - Clerk without Convex
create-better-t-stack --auth clerk --backend hono
```
## Example Compatibility
@@ -203,8 +218,11 @@ create-better-t-stack --frontend tanstack-router
### "Authentication requires a database"
```bash
# Fix by adding database
create-better-t-stack --auth --database postgres --orm drizzle
# Fix by adding database for Better-Auth
create-better-t-stack --auth better-auth --database postgres --orm drizzle
# Or use Clerk with Convex (no database required)
create-better-t-stack --auth clerk --backend convex
```
## Validation Strategy

View File

@@ -33,6 +33,7 @@ create-better-t-stack [project-directory] [options]
- `--database <type>`: `none`, `sqlite`, `postgres`, `mysql`, `mongodb`
- `--orm <type>`: `none`, `drizzle`, `prisma`, `mongoose`
- `--api <type>`: `none`, `trpc`, `orpc`
- `--auth <provider>`: `better-auth`, `clerk`, `none` (see [Options](/docs/cli/options#authentication))
- `--db-setup <setup>`: `none`, `turso`, `d1`, `neon`, `supabase`, `prisma-postgres`, `mongodb-atlas`, `docker`
- `--examples <types...>`: `none`, `todo`, `ai`
- `--web-deploy <setup>`: `none`, `wrangler`, `alchemy`

View File

@@ -217,16 +217,24 @@ create-better-t-stack --frontend none
## Authentication
### `--auth / --no-auth`
### `--auth <provider>`
Include or exclude authentication setup using Better-Auth.
Choose authentication provider:
- `better-auth`: Better-Auth authentication (default)
- `clerk`: Clerk authentication (only with Convex backend)
- `none`: No authentication
```bash
create-better-t-stack --auth
create-better-t-stack --no-auth
create-better-t-stack --auth better-auth
create-better-t-stack --auth clerk
create-better-t-stack --auth none
```
**Note:** Authentication requires both a database and backend framework to be selected. It is automatically disabled when using Convex backend or when no backend is selected.
**Note:**
- `better-auth` requires both a database and backend framework
- `clerk` is only available with Convex backend
- Authentication is automatically set to `none` when using `--backend none` or `--database none` (unless using Convex)
## Addons
@@ -312,7 +320,7 @@ create-better-t-stack \
--runtime bun \
--frontend tanstack-router \
--api trpc \
--auth \
--auth better-auth \
--addons pwa biome \
--examples todo \
--package-manager bun \

View File

@@ -33,7 +33,7 @@ async function createProject() {
backend: "hono",
database: "sqlite",
orm: "drizzle",
auth: true,
auth: "better-auth",
packageManager: "bun",
install: false, // Don't install deps automatically
disableAnalytics: true, // Disable analytics
@@ -258,7 +258,7 @@ create-better-t-stack my-app \
--backend hono \
--database postgres \
--orm drizzle \
--auth \
--auth better-auth \
--yes
```
@@ -269,7 +269,7 @@ const result = await init("my-app", {
backend: "hono",
database: "postgres",
orm: "drizzle",
auth: true,
auth: "better-auth",
yes: true
});
```
@@ -286,7 +286,7 @@ const result = await init("my-app", {
backend: "hono",
database: "postgres",
orm: "drizzle",
auth: true,
auth: "better-auth",
addons: ["biome", "turborepo"],
examples: ["todo"],
packageManager: "bun",