Recommended compiler settings
import type for types that are erased at runtime and a current TypeScript-aware Node, Bun, or bundler runtime. The SDK core uses platform Fetch; use Node.js 18+, a modern browser, or provide a compatible fetch implementation through createKomgaClient.
Import generated types
The package root re-exports generated DTOs, search types, page types, operation response types, and operation error types:content, totalElements, and totalPages may be optional. Narrow or provide defaults before using them. Do not add fields from old service-layer search models when they are not present in the generated type.
Type flat operation parameters
Generated signatures catch wrong parameter names and prevent the removed grouped call shape:bookMetadataUpdateDto in updateBookMetadata. Use the generated query name, including names such as library_id, exactly as exported.
Infer an operation’s result
An operation’s default return type is a Promise of its generated result contract:Parameters<typeof getBookById>[1] therefore includes undefined. In application code, pass { client } as the second argument when using an isolated client. Prefer Awaited<ReturnType<...>> over manually recreating { data, error, request, response } unions.
Public helper types
The package root also exports:KomgaClientOptionsandAuthConfigforcreateKomgaClient.KomgaResultfor the default{ data, error, request, response }result shape.KomgaApiErrorandunwrapfor an explicit throwing boundary.ClientandGeneratedClientConfigfor advanced generated-client integrations.- Generated DTO, page, search, operation response, and operation error types.
Narrow result branches
Useerror === undefined as the discriminant before reading data:
request and response are optional because network or request-construction failures can happen before Fetch returns a response. Successful void operations have data: undefined; binary operations use their generated media type and may require a parseAs option.
Avoid unsafe assertions
Do not cast a result to a DTO before checking its error branch, and do not useany to bypass generated parameter errors:
Next steps
- Configure a client: Fetch configuration
- Call generated operations: Direct API functions
- Choose result or throwing handling: Result handling