---
title: Introduction
description: What @kaaarel/auth is, and what it does not do.
---

# Introduction

`@kaaarel/auth` is server-only auth for TypeScript apps. It runs inside your app, on any framework, and stores its data in your Postgres database.

- **No UI.** Your app keeps its own login, sign-up and settings pages. The package gives you functions and error codes.
- **No client SDK.** You call the package from server code: server functions, loaders, API routes.
- **No runtime dependencies.** It uses only what Bun and Node have built in: `node:crypto`, `fetch` and argon2id.
- **One file of config.** Methods, access rules, e-mails and pages are in one `createAuth()` call.
- **Any framework.** The core works on a web `Request`. TanStack Start and Next.js have adapters; Hono, Bun.serve, SvelteKit, React Router and the others use `auth.withRequest(request)`.

## What you get

| Part | Contents |
| --- | --- |
| Core | Cookie sessions, Google, GitHub, e-mail and password, e-mail verification, password reset, access rules, rate limits, account settings |
| `twoFactor` | TOTP codes (any authenticator app) and recovery codes |
| `workspaces` | Workspaces, members, roles, invites by e-mail |
| `tokens` | API tokens for scripts, CLIs and MCP clients |

## How it works

1. Your page posts a form to your own server code: a server function, a server action, or a POST route.
2. That code calls `auth.password.signIn(data)`.
3. The package checks the password, sets an `HttpOnly` session cookie, and returns `{ ok: true }` or `{ ok: false, error: "invalid_credentials" }`.
4. Your page shows the error in its own words and its own look.

Google and GitHub use redirects, so the package serves a few routes under `/auth/*`: the start of the login, the callback, the e-mail links and sign-out. These routes only redirect. They never render a page.

## Requirements

- Bun 1.2+ or Node 24.7+. Both have argon2id built in.
- PostgreSQL 13+.
- Any framework that gives you a web `Request`. TanStack Start and Next.js (15+) have adapters.

## Design choices

- **Sessions live on the server.** The cookie holds a random token. The database holds only its SHA-256 hash. Sign-out and "sign out everywhere" work at once.
- **Results, not exceptions.** Functions that change something return `{ ok, error }`. `error` is a typed union, so your editor lists every case.
- **Each app has its own users.** There is no central auth server. Each app has its own Google project, so the Google screen shows the app's own name.
