Supabase + Astro authentication scaffolding in one command.
astro-auth-kit generates an Astro project with production-ready auth — SSR sessions, email/password, OAuth (Google/GitHub), password reset, protected routes, Tailwind, and a set of reusable components. Styled and working out of the box.
| SSR sessions | Middleware + cookies with @supabase/ssr, automatic refresh |
| Full auth | Sign in, register, email confirmation, OAuth, password reset |
| Protected routes | Explicit requireAuth / requireGuest per page |
| UI | Tailwind + Button, Input, Card, AuthForm components (shadcn-style) |
| Friendly messages | Supabase errors translated to clear text |
@/* alias |
Clean imports configured in tsconfig.json |
Prerequisite: an existing Astro project (or create one):
bun create astro@latest my-app --template basics
cd my-appRun the CLI:
bun add -d astro-auth-kit
bunx astro-auth-kit initnpm:
npx astro-auth-kit initworks directly.
The CLI will ask whether you already have a Supabase project (URL + publishable key). If not, it generates a .env.example with placeholders to fill in later.
init detects and configures for you:
- SSR — if
output: "server"is missing, it asks for an adapter (node/vercel/cloudflare/netlify), installs it and patchesastro.config.*(with a.bakbackup) - Tailwind — if absent, runs
astro add tailwind --yes(v4 + vite plugin) @/*alias — addspathstotsconfig.json.env— with your credentials, or.env.examplewith placeholders
Nothing is overwritten: existing files are skipped, and any config it touches keeps a .bak.
src/
├── actions/index.ts # signin, signout, register, forgotPassword, updatePassword
├── components/
│ ├── AuthForm.astro # reusable auth form
│ └── ui/{Button,Input,Card}.astro
├── lib/supabase/{client,server}.ts
├── middleware.ts
├── pages/
│ ├── signin.astro / register.astro / forgot-password.astro / reset-password.astro
│ ├── dashboard.astro # example protected route
│ └── api/auth/callback.ts # + oauth/[provider].ts
└── styles/global.css # design tokens (light/dark)
- Providers → enable Email and any others you want (Google/GitHub)
- For OAuth, create an OAuth App in the provider and paste the client ID/secret
- Set the redirect URL:
https://<ref>.supabase.co/auth/v1/callback - Toggle "Allow email" / "allow no email" as needed
The components and pages are yours — edit them freely:
// src/actions/index.ts — custom validation
import { z } from "astro/zod";
export const server = {
register: defineAction({
...authActions.register,
input: z.object({ email: z.email(), password: z.string().min(8) }),
}),
};Or write your own action with the server client:
import { createSupabaseServerClient } from "astro-auth-integration/server";
// full control| Package | Role |
|---|---|
astro-auth-kit |
Scaffolding CLI |
astro-auth-integration |
Astro integration (middleware, protect, actions, oauth) |
astro-auth-core |
Shared types and utilities (error messages, env) |
bun install
bun run build # builds packages/*
bun run typecheck # type checks
bun run lint # Biomeastro-auth-kit — Supabase auth for Astro, in one command.