github bknd-io/bknd v0.9.0

latest releases: v0.17.1, v0.17.0, v0.16.1...
6 months ago

🚀 New Features

Create a local API (#89)

When deploying bknd in a full stack framework, you may want to make use of the API SDK without traveling the network. It was possible before, but not so handy. Now you can create a local API from the app instance easily:

// check your frameworks' doc
const app = createApp(); 

// this api instance won't travel the network!
const api = app.getApi();

// you can also pass `headers` or the `request` object to get the API tied to a specific user for authorization
app.getApi({ request });
app.getApi({ headers });

Next.js App Router support (#89)

The Next.js example and CLI starter template has been updated to App Router. Get started by running:

npx bknd create -i nextjs

CleanShot 2025-03-05 at 09 40 26

AWS Lambda adapter (#102)

The official AWS Lambda adapter is now available in the docs and CLI starter:

npx bknd create -i aws

The CLI starter also includes a deploy.sh script that automatically pulls static assets, bundles the lambda and creates all required AWS resources. But make sure to create a Turso database first (database as file is generally possible but increases the deployment size and causes issues with concurrency).

import { serveLambda } from "bknd/adapter/aws";

export const handler = serveLambda({
   connection: {
      url: process.env.DB_URL!,
      authToken: process.env.DB_AUTH_TOKEN!
   },
   assets: {
      mode: "local",
      root: "./static"
   }
});

Data Bulk Updates & more (#99 & #104)

The data API and controller has been updated to allow bulk insertions, updates and deletions:

// many insertions
await api.data.createMany("posts", [
   { title: "Hello, World!" },
   { title: "Again, Hello." },
]);

// many updates
await api.data.updateMany("posts", { views: { $gt: 1 } }, {
   title: "viewed more than once"
});

// many deletions
await api.data.deleteMany("posts", { views: { $lte: 1 } });

Furthermore, a new readOneBy() method has been added to retrieve a single item by any given query. It's a convenience wrapper around readMany but always returns a single item:

await api.data.readOneBy("posts", { title: "Hello, World!" });

Auth UI improvements (#98)

Authentication settings and strategies are now directly inside /auth (still available in advanced settings) with a more appealing UX/UI.

SettingsStrategies
Auth Settings Auth Strategies

Report of unindexed fields (#96)

If you're like me, you just forget about adding indices when implementing a new feature quickly until you inspect the performance or the overall reads. That's not an issue with only a few queries, but as you keep adding, it's hard to keep track and spot bottlenecks. The with property already reduces the amount of queries you need to execute, and now, bknd will automatically log a warning into the console every time you're using an attribute for sorting or filtering that hasn't been indexed:

[WRN] 2025-03-05 10:02:37 Field "posts.title" used in "where" is not indexed

So now, to spot potential performance bottlenecks you only have to keep an eye on the console! You can add new indices by heading to the advanced settings at /settings/data/indices (documentation is coming soon, the UI will also be updated to make it even easier).

Other Changes

  • improve console with timestamps by @dswbx in #94
  • media more mime types and add dropzone mime checker by @dswbx in #95
  • fix ManyToManyRelation to respect select from with query by @dswbx in #92
  • feat/ci-tests by @dswbx in #97
  • fix active sidebar active item, added error boundaries for relational form fields, fixed schema diagram for m:n relations by @dswbx in #100
  • added missing cache directives to media adapter serving by @dswbx in #101

Full Changelog: v0.8.1...v0.9.0

Don't miss a new bknd release

NewReleases is sending notifications on new releases.