Skip to main content
The SDK ships Zod schemas for DTOs and helpers for runtime validation.

Validate a response

import { BookDtoSchema, validateResponse } from 'komga-sdk';

const book = validateResponse(BookDtoSchema, responseData);

Safe validation

import { BookDtoSchema, safeValidateResponse } from 'komga-sdk';

const result = safeValidateResponse(BookDtoSchema, responseData);
if (result.success) {
  console.log(result.data);
} else {
  console.log(result.error);
}

Pagination schemas

import { createPageSchema, BookDtoSchema } from 'komga-sdk';

const PageBookSchema = createPageSchema(BookDtoSchema);
const page = PageBookSchema.parse(rawData);

Nullish fields

Fields that can be null from the API are represented as nullish in schemas. This keeps optional TypeScript types compatible with runtime responses.

Next steps