v0.13.0

bknd-io/bkndv0.13.0May 27, 2025by dswbx

AI Summary

A major update featuring a custom JSON Schema implementation (`jsonv-ts`) for better validation and automatic OpenAPI generation, plus custom storage options for the API client.

Key Highlights

  • Custom JSON Schema implementation (`jsonv-ts`)
  • Automatic OpenAPI generation for authenticated routes
  • Custom storage support for API client
  • Improved coercion and validation

New Features

  • jsonv-ts integration
  • OpenAPI generation
  • Custom storage options

Full Release Notes

## Custom JSON Schema & integrated OpenAPI (https://github.com/bknd-io/bknd/pull/172, https://github.com/bknd-io/bknd/pull/173)
This was quite a biggie. Since bknd fully relies on JSON Schema, the available libraries to work with it weren't all that pleasant to work with. Either they only include a validator (`@cfworker/json-schema`, `json-schema-library`) or are tied to another use-case (`@sinclair/typebox`, `zod`) adding JSON Schema as an after thought. 

But implementing native MCP support and visual workflows that are even more reliant on JSON Schema, this wasn't acceptable anymore. That's why I went ahead creating my own implementation: [jsonv-ts](https://github.com/dswbx/jsonv-ts)

It has a zod-inspired API but strictly targeting JSON Schema as the main priority. It also includes a validator that is currently passing 74% of the ~2000 tests provided by the official test suite – but since it produces clean JSON Schema, any validator can be used. Additional integrated features are:
* Automatic and customizable coercion (required for `SearchParams`)
* Property-level customizable, additional validation
* Hono middleware to validate targets such as query, json, form, parameters, etc.
* Automatic OpenAPI generation for routes that use the middleware

Not everything JSON Schema related has been moved over yet, only all route validations and one of the most complex schema which is the recursive repository query. So now every instance has full OpenAPI specs with the current user automatically authenticated:

https://github.com/user-attachments/assets/4c70c9f0-0240-4d8a-9624-9370bfc68783

## API: Custom Storage Support (https://github.com/bknd-io/bknd/pull/174)
You can now instantiate an `Api` instance with a custom `storage` option to store the auth state in whatever storage you'd like (`localStorage` compatible API):

```typescript
export type ApiOptions = {
    storage?: {
        getItem: (key: string) => string | undefined | null | Promise<string | undefined | null>;
        setItem: (key: string, value: string) => void | Promise<void>;
        removeItem: (key: string) => void | Promise<void>;
    };
    // ...
}
```

This option may also be passed via ClientProvider:

```tsx
<ClientProvider storage={window.localStorage} />
```

Helpful for using a custom client side storage such as local storage or browser storage (when used in a chrome extension).

## Other Changes
* admin: data/auth route-driven settings and collapsible components by @dswbx in https://github.com/bknd-io/bknd/pull/168
* remove batching workaround for Turso AWS endpoints by @dswbx in https://github.com/bknd-io/bknd/pull/171


**Full Changelog**: https://github.com/bknd-io/bknd/compare/v0.12.0...v0.13.0