@played/auth (0.5.0)
Published 2026-05-19 23:28:25 +00:00 by enricobuehler
Installation
@played:registry=https://git.unom.io/api/packages/played/npm/npm install @played/auth@0.5.0"@played/auth": "0.5.0"About this package
@played/auth
Shared auth package for played.* games. Wraps better-auth with a Drizzle adapter, owns the auth Postgres schema (users, sessions, accounts, verifications), and emits cookies scoped to the parent domain so a session created on one game is valid on every other game.
Usage
Server
import { createAuth } from "@played/auth/server";
import * as authSchema from "@played/auth/server/schema";
import { db } from "./db";
export const auth = createAuth({
db,
secret: process.env.BETTER_AUTH_SECRET!,
baseURL: process.env.BETTER_AUTH_URL!,
trustedOrigins: [process.env.FRONTEND_URL!],
cookieDomain: process.env.NODE_ENV === "production" ? ".played.click" : undefined,
isProduction: process.env.NODE_ENV === "production",
appName: "filler by played",
socialProviders: {
discord: {
clientId: process.env.DISCORD_CLIENT_ID!,
clientSecret: process.env.DISCORD_CLIENT_SECRET!,
},
},
});
The drizzle db must include the auth schema tables — barrel-export them from @played/auth/server/schema in your game's schema module.
Client
import { createPlayedAuthClient } from "@played/auth/client";
import type { auth } from "@your-game/api/auth";
export const authClient = createPlayedAuthClient<typeof auth>({
baseURL: import.meta.env.VITE_API_URL,
});
Migrations
Owned by this package (./drizzle). Run drizzle-kit push against the shared Postgres before any game boots.
Dependencies
Development Dependencies
| ID | Version |
|---|---|
| @types/bun | latest |
| @types/react | ^19.0.0 |
| better-auth | ^1.6.10 |
| drizzle-orm | 1.0.0-rc.2-6e355d0 |
| react | ^19.0.0 |
| tsdown | ^0.22.0 |
| typescript | ^6.0.3 |
Peer Dependencies
| ID | Version |
|---|---|
| better-auth | ^1.6.10 |
| drizzle-orm | 1.0.0-rc.2-6e355d0 |
| react | ^19.0.0 |