Skip to content

Backend · Reference

SDK and package exports

Choose the correct package entry point for browser components, server middleware, schemas, APIs, and project authorization.

@krak-stack/auth publishes distinct entry points for browser UI, Effect services, API contracts, schemas, and authorization. Import the narrowest entry point that matches the runtime boundary.

Export map

Entry pointUse
@krak-stack/auth/componentsProvider, auth forms, account and organization controls, and UI permission helpers
@krak-stack/auth/serverProxying, AuthMiddleware, AuthService, ActorRequired, actors, and policies
@krak-stack/auth/accessTyped project access catalogs and policy construction
@krak-stack/auth/access/matrixGenerated project permission reference table
@krak-stack/auth/apiCombined Effect HttpApi contracts
@krak-stack/auth/authOwned browser authentication HttpApi contract and schemas
@krak-stack/auth/schemaShared user, organization, session, project, and API-key schemas
@krak-stack/auth/queryQuery helpers for Effect Atom clients
@krak-stack/auth/adminAdministrative API contract
@krak-stack/auth/extraBrowser-facing extra API contract
@krak-stack/auth/tailwind.cssTailwind source registration for component classes

Use @krak-stack/auth/auth when constructing an Effect HttpApiClient or AtomHttpApi client for the browser authentication endpoints. UI consumers should import the packaged components and atoms directly from @krak-stack/auth/components.

Server configuration

AuthClientConfig resolves its base URL from an explicit option, then KRAKSTACK_AUTH_URL, then VITE_KRAKSTACK_AUTH_URL. Server code should prefer KRAKSTACK_AUTH_URL. It resolves the trusted credential from an explicit redacted value or KRAKSTACK_AUTH_SERVICE_API_KEY.

ts
import { AuthClientConfig, AuthService } from "@krak-stack/auth/server";
import { Effect } from "effect";

const currentSession = Effect.gen(function* () {
  const auth = yield* AuthService;
  return yield* auth.getSession();
}).pipe(Effect.provide(AuthClientConfig.layer()));

Use API middleware for request-scoped session forwarding rather than manually constructing headers.

Component distribution status

The React component bundle uses the peer dependencies declared by the package and Krakstack/shadcn UI primitives from @krak-stack/registry. Follow React components and CSS. The server-only subpaths have a smaller and clearer integration boundary.

The generated HTTP operation reference is available at API reference.