Search documentation

Search documentation pages and headings.

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/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/better-authBetter Auth contract
@krak-stack/auth/tailwind.cssTailwind 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.

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 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.