npm package: @rblez/authly
Description: Local auth dashboard for Next.js + Supabase
Author: rblez
Latest version: 0.5.1

# Authly

**Authly** is a local auth dashboard for Next.js + Supabase. No global installs. No third-party dependencies. Your data, your server.

```bash
npx @rblez/authly
```

<p align="center">
  <img src="https://img.shields.io/badge/status-in_construction-black" alt="Status">
  <img src="https://img.shields.io/node/v/@rblez/authly" alt="Node version">
  <img src="https://img.shields.io/github/license/rblez/authly" alt="License">
</p>

---

## Why it exists

- I don't want to depend on Supabase Auth, Clerk, or Better Auth
- I want auth ready in 10 minutes on any new project
- I want to manage users from a panel while developing
- Everything runs on my own infrastructure

---

## How it works

1. Run `npx @rblez/authly` in your project
2. It detects your stack (Next.js App Router)
3. Starts a dashboard at `localhost:1284`
4. Configure providers, roles, sessions from the UI
5. Generates files, migrations, and env vars automatically
6. While running — live user panel via internal API
7. In production — it doesn't exist, zero exposed surface

---

## Quick start

```bash
# 1. In any project directory
npx @rblez/authly

# 2. Set Supabase credentials
export SUPABASE_URL=""
export SUPABASE_ANON_KEY=""
export SUPABASE_SERVICE_ROLE_KEY=""
export AUTHLY_SECRET="$(openssl rand -hex 32)"

# 3. Configure OAuth providers
export GOOGLE_CLIENT_ID=""
export GOOGLE_CLIENT_SECRET=""
export GITHUB_CLIENT_ID=""
export GITHUB_CLIENT_SECRET=""

# 4. Dashboard runs at http://localhost:1284
```

---

## Installation

```bash
# One-off (recommended)
npx @rblez/authly

# Or install locally
npm install @rblez/authly -D
npx authly
```

**Requirements:**
- Node.js 20+
- A Supabase project
- A Next.js project with App Router

---

## Setup

Authly connects via environment variables or `authly.config.json`:

```json
{
  "framework": "nextjs",
  "supabase": {
    "url": "https://xxx.supabase.co",
    "anonKey": "",
    "serviceRoleKey": ""
  }
}
```

Or via `.env.local`:

```bash
# required
SUPABASE_URL=""
SUPABASE_ANON_KEY=""
SUPABASE_SERVICE_ROLE_KEY=""
AUTHLY_SECRET=""          # random string for JWT signing

# optional - providers
GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""
GITHUB_CLIENT_ID=""
GITHUB_CLIENT_SECRET=""

# optional - overrides
AUTHLY_PORT=1284
```

---

## Dashboard sections

| Section | What it does |
|---|---|
| **Init** | Connects to your project, detects stack |
| **Providers** | Enable Google, GitHub, Discord — buttons appear auto |
| **UI** | Generates login/signup TSX with SimpleIcon provider buttons |
| **Routes** | Auth middleware, redirects, UTM tracking |
| **Roles** | Role system: create roles, assign/revoke to users |
| **API Keys** | Generate and manage programmatic API keys |
| **Env** | Generates documented `.env.local` |
| **Migrate** | Runs SQL migrations without Supabase dashboard |
| **Users** | Live user panel via internal API |
| **Audit** | Checks config, env vars, and database connectivity |

---

## API Reference

| Method | Endpoint | Description |
|---|---|---|
| `GET` | `/api/health` | Health check |
| `GET` | `/api/auth/providers` | List OAuth providers + status |
| `POST` | `/api/auth/register` | Sign up email + password |
| `POST` | `/api/auth/login` | Sign in email + password |
| `GET` | `/api/auth/me` | Verify session (Bearer token) |
| `GET` | `/api/users` | List users from Supabase |
| `GET` | `/api/roles` | List roles |
| `POST` | `/api/roles` | Create role |
| `POST` | `/api/keys` | Generate API key |
| `GET` | `/api/migrations` | List available migrations |
| `POST` | `/api/audit` | Run config audit |

---

## Stack

| Layer | Tech |
|---|---|
| **Runtime** | Node.js 18+ |
| **Server** | Hono |
| **Database** | Supabase (PostgreSQL) |
| **Sessions** | JWT via `jose` (HS256) |
| **Password** | bcryptjs |
| **OAuth** | Direct provider APIs + authly SDK |
| **Output** | Next.js (TSX) + Supabase migrations |

---

## Design Rules

- Black by default, always
- SF Pro Text + SimpleIcons for provider logos
- Zero data on third parties — everything in your Supabase
- Never runs in production — development only
- Plug-and-play — functional in under 10 minutes

---

## Roadmap

### v0.1 — Core (personal use)
- [x] `npx @rblez/authly` starts local server
- [x] Base dashboard UI (black, SF Pro, Remixicon)
- [x] Init — detects Next.js + connects Supabase
- [x] Generates `users` table migration
- [x] Generates `.env.local`

### v0.2 — Auth in production
- [ ] Provider: Magic Link (Resend)
- [x] Provider: Google OAuth
- [x] Provider: GitHub OAuth
- [x] Scaffold login/signup TSX
- [x] Protected route middleware
- [x] Password auth (login/register)

### v0.3 — User panel
- [x] Internal API that fetches users from Supabase
- [x] Live user view in dashboard
- [x] Basic roles (admin / user)

### v0.4 — Complete DX
- [x] API Keys — generation and validation
- [x] UTM tracking on redirects
- [x] `authly audit` — detects config issues
- [ ] Inline documentation in dashboard

### v1.0 — Public Release
- [ ] Tested on Tiendly, smsnumerovirtual, and a third project
- [x] Complete README
- [ ] Published on npm as `@rblez/authly`
- [x] Public repo on github.com/rblez/authly

### Future
- [ ] Multi-DB support (PostgreSQL direct, MongoDB, etc.)

---

## License

MIT — rblez