Use a runtime like Node, Bun or
Cloudflare (workerd). This will run the API and UI in the runtime's
native server and serves the UI assets statically from node_modules.
Run it inside your React framework of choice like Next.js,
Astro or Remix.
There is also a fourth option, which is running it inside a
Docker container. This is essentially a wrapper around the CLI.
Regardless of the method you choose, at the end all adapters come down to the actual
instantiation of the App, which in raw looks like this:
import { createApp, type CreateAppConfig } from "bknd";// create the appconst config = { /* ... */} satisfies CreateAppConfig;const app = createApp(config);// build the appawait app.build();// export for Web API compliant envsexport default app;
In Web API compliant environments, all you have to do is to default exporting the app, as it
implements the Fetch API.
As initial configuration, you can either pass a partial configuration object or a complete one
with a version number. The version number is used to automatically migrate the configuration up
to the latest version upon boot. The default configuration looks like this:
The plugins property is an array of functions that are called after the app has been built,
but before its event is emitted. This is useful for adding custom routes or other functionality.
A simple plugin that adds a custom route looks like this:
Since each plugin has full access to the app instance, it can add routes, modify the database
structure, add custom middlewares, respond to or add events, etc. Plugins are very powerful, so
make sure to only run trusted ones.
The seed property is a function that is called when the app is booted for the first time. It is used to seed the database with initial data. The function is passed a ModuleBuildContext object: