> ## Documentation Index
> Fetch the complete documentation index at: https://docs.theauth.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick Start

> This walks through the smallest working theauth-go server: an in-memory store, magic links, and email/password sign-in, wired to a chi router in a handful of lines.

This walks through the smallest working theauth-go server: an in-memory store, magic links, and email/password sign-in, wired to a chi router in a handful of lines.

## Minimal server (magic links + email/password)

```go theme={"dark"}
package main

import (
    "net/http"

    "github.com/glincker/theauth-go/v2"
    "github.com/glincker/theauth-go/v2/storage/memory"
    "github.com/go-chi/chi/v5"
)

func main() {
    a, _ := theauth.New(theauth.Config{
        Storage: memory.New(),
        BaseURL: "http://localhost:8080",
    })

    r := chi.NewRouter()
    a.Mount(r) // wires /auth/* endpoints

    r.With(a.RequireAuth()).Get("/me", func(w http.ResponseWriter, r *http.Request) {
        user, _ := theauth.UserFromContext(r.Context())
        w.Write([]byte("hello " + user.Email))
    })

    http.ListenAndServe(":8080", r)
}
```

Run it:

```bash theme={"dark"}
go run main.go
```

Sign up:

```bash theme={"dark"}
curl -s -X POST http://localhost:8080/auth/email-password/signup \
  -H "Content-Type: application/json" \
  -d '{"email":"you@example.com","password":"supersecret123"}'
```

Or request a magic link:

```bash theme={"dark"}
curl -s -X POST http://localhost:8080/auth/magic-link \
  -H "Content-Type: application/json" \
  -d '{"email":"you@example.com"}'
```

## Add Postgres storage

Replace `memory.New()` with the Postgres adapter for persistent sessions:

```go theme={"dark"}
import (
    "github.com/jackc/pgx/v5/pgxpool"
    "github.com/glincker/theauth-go/v2/storage/postgres"
)

pool, _ := pgxpool.New(ctx, os.Getenv("DATABASE_URL"))
a, _ := theauth.New(theauth.Config{
    Storage: postgres.New(pool),
    BaseURL: "https://myapp.com",
})
```

## Mounted endpoints

`a.Mount(r)` wires the following routes:

| Endpoint | Purpose |
| - | - |
| `POST /auth/magic-link` | Request a sign-in link |
| `GET /auth/magic-link/verify` | Consume the link token, issue session |
| `POST /auth/email-password/signup` | Register, sets session cookie |
| `POST /auth/email-password/signin` | Sign in, sets session cookie |
| `POST /auth/email-password/forgot` | Request a password reset (silently 200 for unknown emails) |
| `POST /auth/email-password/reset` | Consume reset token, revoke all sessions |
| `GET /auth/me` | Current user (requires auth) |
| `DELETE /auth/sessions/current` | Sign out |

OAuth providers (`GET /auth/providers/{name}/start` and `/callback`): 12 built-in providers, including github, google, microsoft, discord, apple, facebook, slack, gitlab, bitbucket, twitch, linkedin, and x. See [Add an OAuth Provider](/go/guides/add-oauth-provider) for the full list.

WebAuthn: `/auth/webauthn/register/{begin,finish}`, `/auth/webauthn/login/{begin,finish}`, `/auth/webauthn/credentials`.

TOTP: `/auth/totp/enroll/{begin,finish}`, `/auth/totp/verify`, `/auth/totp/recovery`, `DELETE /auth/totp`.

## Next steps

* [Storage Backends](/go/getting-started/storage-backends) - Memory vs Postgres, migration strategy.
* [Add an OAuth Provider](/go/guides/add-oauth-provider) - Wire GitHub, Google, Microsoft, or Discord.
* [Enable WebAuthn Passkeys](/go/guides/webauthn-passkeys) - Passkey registration and discoverable login.
* [Configuration Reference](/go/reference/configuration) - Full `theauth.Config` shape.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.