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 point | Use |
|---|---|
@krak-stack/auth/components | Provider, auth forms, account and organization controls, and UI permission helpers |
@krak-stack/auth/server | Proxying, AuthMiddleware, AuthService, ActorRequired, actors, and policies |
@krak-stack/auth/access | Typed project access catalogs and policy construction |
@krak-stack/auth/access/matrix | Generated project permission reference table |
@krak-stack/auth/api | Combined Effect HttpApi contracts |
@krak-stack/auth/schema | Shared user, organization, session, project, and API-key schemas |
@krak-stack/auth/query | Query helpers for Effect Atom clients |
@krak-stack/auth/admin | Administrative API contract |
@krak-stack/auth/extra | Browser-facing extra API contract |
@krak-stack/auth/better-auth | Better Auth contract |
@krak-stack/auth/tailwind.css | Tailwind source registration for component classes |
The package root re-exports many, but not all, component APIs. Import useKrakstackAuth, useKrakstackAuthProjectConfig, usePermissions, HasPermission, and useHasPermission from @krak-stack/auth/components until the root export surface is unified.
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.
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 current emitted React component bundle still imports Krakstack/shadcn UI aliases and several runtime packages from the consumer environment. Validate the packed package in the target application and 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.