Get started

Pick a track: people signing in, or agents calling.

Most apps need both. A person logs in and gets a session. An AI agent, an MCP client or a script presents a scoped token instead. theAuth handles each with its own mechanism, in one library, in TypeScript or Go.

How the two differ

A session proves who someone is. A token proves what a caller may do.

Human auth
Sign-in methods in, one server-side session out. The browser holds a cookie. Your app asks theAuth who the user is. Revoke by ending the session.
AI agent auth
The agent has an owner and a token with permission patterns, an expiry and an audit row per decision. MCP clients get OAuth 2.1 access tokens bound to one resource. Revoke one agent without touching anyone else.
People and agents enter through the same library and leave with different credentials. A person gets a server-side session. An agent gets a scoped token with an owner, an expiry and an audit trail.

Track 1

Human auth in about ten lines.

Install, configure one sign-in method, read the signed-in user. Magic links need no password database to start, and passkeys, TOTP, OAuth and SAML add on top.

1 Scaffold a full app, or add the package to your own.

pnpm create @glinr/theauth-app

Or add it to an existing project. The SQLite driver is a peer dependency, so install it too:

pnpm add @glinr/theauth sql.js

npm users: npm create @glinr/theauth-app and npm install @glinr/theauth sql.js.

2 Create the instance and send a sign-in link.

auth.ts
import { createTheAuth } from "@glinr/theauth";

const theauth = await createTheAuth({
  database: { provider: "sqlite", url: "app.db" },
  baseUrl: "http://localhost:3000",
  auth: { session: { secret: process.env.SESSION_SECRET! } }, // 32+ characters
  magicLink: {
    appUrl: "http://localhost:3000",
    sendMagicLink: async (email, _token, url) => {
      console.log(`sign-in link for ${email}: ${url}`);
    },
  },
});

await theauth.magicLink?.sendLink("[email protected]");

Track 2

AI agent auth: identities, scoped tokens, MCP.

Give each agent its own owner, permissions and audit trail, or put an OAuth 2.1 authorization server in front of your MCP server so clients you have never met can register and sign in.

1 Install the core. Add the Hono adapter if you want the MCP OAuth endpoints.

pnpm add @glinr/theauth sql.js
pnpm add @glinr/theauth-hono hono @hono/node-server

2 Create an agent and authorize a call by its token.

agent.ts
import { createTheAuth } from "@glinr/theauth";

const theauth = await createTheAuth({
  database: { provider: "sqlite", url: "app.db" },
  agents: { enabled: true },
});

const agent = await theauth.agent.create({
  ownerId: "user-123", // a row that exists in theauth_users
  name: "report-bot",
  type: "autonomous",
  permissions: [{ resource: "reports:*", actions: ["read"] }],
});
// agent.token is "kv_...", shown once. Store it now.

const result = await theauth.authorizeByToken(agent.token, {
  action: "read",
  resource: "reports:q3",
});
// result.allowed === true, result.auditId links to the audit row

Before you run two servers

Pick where short-lived state lives

Rate limit counters, device codes and nonces default to process memory. Switch one line when you add instances.

// default, no config
createTheAuth({ /* ... */ })
  • Atomic counters: yes.
  • Shared across instances: no.
  • Lost on restart. Fine for development and one process.

Secondary storage holds rate limit counters, device codes and other short-lived state. See the secondary storage docs for the interface and tradeoffs.

Where to go next

Commands checked against npm and the Go module proxy on 2026-10-08: @glinr/theauth 0.6.0, @glinr/theauth-hono 4.0.0, @glinr/create-theauth-app 0.3.0, theauth-go v2.7.1.

Get started

Give your first agent an identity.

Install the package, create an agent with scoped permissions, and read its first audit record. The core runs on Postgres, SQLite, MySQL or D1, and the Go module needs a single go get.

  • npm install @glinr/theauth
  • go get github.com/glincker/theauth-go/v2
Or skip hosting with theAuth Cloud