Skip to content
0

Upgrade to KatanaKit v4 ​

This guide migrates you from 3.x to 4.x. Two changes need attention: the logger API and the query layer's return shape.

bash
npm install katanakit-js@^4

Breaking changes ​

Logger API simplified (4.0.1) ​

useLogger now takes (message, data?, level?) with levels reduced to log | warn | error. The info and debug levels are gone.

The Strategy abstraction — LogStrategy, ConsoleStrategy, useSetLogLevel, useSetStrategy — and useLog were removed. Logging maps directly onto the native console.

Before (3.x):

ts
import { useLog, useSetLogLevel } from "katanakit-js";

useSetLogLevel("debug");
useLog("fetching users", { id: 25 }, "info");

After (4.x):

ts
import { useLogger } from "katanakit-js";

useLogger("fetching users", { id: 25 }, "log");

Query layer runs on TanStack Query Core (4.0.3) ​

@tanstack/query-core ships as a dependency (no separate install), the full engine is re-exported from katanakit-js, and every adapter — useQuery/useMutation for React, Vue, Solid, Svelte and Angular — is now a thin binding over it.

This changes the result object you receive. You get TanStack's native shape back: isPending, isFetching, isSuccess, isError, data, error, status, fetchStatus, refetch, mutate, reset.

Before (3.x, hand-rolled QueryClient/QueryCache): a custom result shape with correctness gaps — no-op invalidateQueries, blocking refetch instead of stale-while-revalidate, no infinite queries, no optimistic updates.

After (4.x):

ts
const { data, isPending, isError, refetch } = useQuery({ queryKey: ["users"], queryFn });

If you destructured fields that no longer exist, they are the breaking part — the query keys themselves are unchanged, and invalidateQueries now matches by array prefix instead of serialized string, so ["users"] correctly invalidates ["users", 1].

Changes that alter behaviour ​

None of these are import-breaking, but they change what your code does:

  • useKatanaFetch renamed to useRequest (4.0.0) — the Vue reactive-fetch composable. useKatanaFetch remains as a deprecated alias, so you can move at your own pace.
  • SSRF hardening (4.0.0) — useFetch fails closed on redirects (redirect: "error"). If a configured endpoint redirects, the request now errors instead of following it.
  • DOM sanitizer (4.0.0) — srcdoc is rejected outright, and data: URIs are restricted to raster images.
  • Express app export is now lazy (4.0.1) — importing katanakit-js/adapters/express no longer builds the app as a side effect.
  • Prisma subpath no longer throws without DATABASE_URL (4.0.0) — the client loads lazily.
  • Notion and WordPress return Safe Results when unconfigured (4.0.0) — instead of throwing.
  • Pagination caps (4.0.1) — useWpListAllPosts, useNotionListAllBlockChildren and useNotionListAllDatabasePages now default to maxItems = 1000.

Added in v4 ​

  • Framework adapters — React, Solid, Svelte and Angular as new optional subpaths (katanakit-js/adapters/react, /solid, /svelte, /angular), each bridging the shared query cache and HTTP layer to its native reactivity.
  • Notion adapter (katanakit-js/adapters/notion) — Pages, Blocks, Databases, Users and Search with auto-pagination helpers, all returning FetchResult.
  • WordPress adapter (katanakit-js/adapters/wordpress) — CRUD over Posts, Pages, Media, Categories, Tags, Comments and Users, plus _fields, _embed, ACF support and batch operations.
  • Bun server adapter (4.0.1) — katanakit-js/adapters/bun, a Bun-native alternative to Express with a typed route table and a dummyjson.com demo.

Migration checklist ​

  1. Install katanakit-js@^4.
  2. Replace useLog/useSetLogLevel call sites with useLogger, dropping info and debug.
  3. Re-check every useQuery/useMutation destructure against TanStack's result object.
  4. Rename useKatanaFetch to useRequest (the alias still works).
  5. Revisit anything relying on redirects being followed.
  6. Run your test suite.

Full detail per release: changelog.

Released under the MIT License.