⚠️ Native SQLite and unified connections (#186, #188, #193)
Warning
This is a breaking change, it requires Node.js >= 22, and for non-edge environments to explicitly use the libsql
function to continue using LibSQL
Previously there was a hard dependency to LibSQL. While it's still recommended and supported as a first-party, bknd will now use the built-in SQLite implementation depending on your environment:
- Node: uses
node:sqlite
– this now requires Node.js >= 22, the current LTS - Bun: uses
bun:sqlite
- Deno: uses
node:sqlite
- Cloudflare: uses D1
To make this maintainable, the connections and especially the SQLite connections have been refactored and generalized. To explicitly use LibSQL as the connection, wrap the connection object around libsql
:
// bknd.config.ts
import { libsql } from "bknd/data";
export default {
connection: libsql({ url: "<url>", authToken: "<token>" })
}
Improved plugins (#187)
Plugins got a massive update to allow them to become a lot more powerful. They can now supply additional schema required for the plugin to work, as well as inject into app lifecycle events. To start off, there are a few useful plugins added. E.g. you can now automatically sync your types every time you update your schema:
// bknd.config.ts
import type { BkndConfig } from "bknd";
import { showRoutes, syncTypes } from "bknd/plugins";
export default {
options: {
plugins: [
// console logs a list of registered routes the first time the app boots
showRoutes({ once: true }),
// writes down the schema types on boot and config change
syncTypes({
enabled: true,
write: async (et) => {
// customize the location and the writer
await Bun.write("bknd-types.d.ts", et.toString());
},
}),
],
},
} as const satisfies BkndConfig;
Docs on how to create your own plugins will follow soon, but you can take a look at it here.
App drivers (#190)
Unlike adapters (e.g. for storage, or authentication), app drivers can be defined before initialization without the ability to modify them in the UI. Drivers can be used to send emails, or to cache assets.
// bknd.config.ts
import type { BkndConfig } from "bknd";
import { resendEmail, memoryCache } from "bknd/core";
export default {
options: {
drivers: {
email: resendEmail({ apiKey: "..." }),
cache: memoryCache(),
},
},
} as const satisfies BkndConfig;
Currently there are a few built-in drivers available, such as:
- email: Resend, MailChannels, AWS SES
- cache: in-memory (LRU), Cloudflare KV
It's very straightforward to add your own driver, docs will follow soon. Read more about it here if you're curious.
Other Changes
- admin: add options such as logo return path when served static by @dswbx in #191
- fix cloudflare r2 adapter range requests by @dswbx in #195
- Update docker.mdx by @stormbyte in #194
New Contributors
- @stormbyte made their first contribution in #194
Full Changelog: v0.14.0...v0.15.0