When run with Node.js, a version of 22 (LTS) or higher is required. Please
verify your version by running node -v, and
upgrade if necessary.
Now create a bknd.config.ts file in the root of your project. If you created the project using the CLI starter, this file is already created for you.
bknd.config.ts
import type { SolidStartBkndConfig } from "bknd/adapter/solid-start";import { em, entity, text, boolean } from "bknd";import { secureRandomString } from "bknd/utils";const schema = em({ todos: entity("todos", { title: text(), done: boolean(), }),});// register your schema to get automatic type completiontype Database = (typeof schema)["DB"];declare module "bknd" { interface DB extends Database {}}export default { connection: { url: "file:data.db", }, options: { // the seed option is only executed if the database was empty seed: async (ctx) => { // create some entries await ctx.em.mutator("todos").insertMany([ { title: "Learn bknd", done: true }, { title: "Build something cool", done: false }, ]); // and create a user await ctx.app.module.auth.createUser({ email: "test@bknd.io", password: "12345678", }); }, }, config: { data: schema.toJSON(), auth: { enabled: true, jwt: { secret: secureRandomString(32), }, }, }, // please run `bun bknd copy-assets --out public/admin` to copy the admin assets into the public directory // alternatively add this as a postinstall script in your package.json like this: // "postinstall": "bknd copy-assets --out public/admin" adminOptions: { adminBasepath: "/admin", assetsPath: "/admin/", // trailing slash is important },} satisfies SolidStartBkndConfig;
See bknd.config.ts for more information on how to configure bknd. The SolidStartBkndConfig type extends the BkndConfig type with the following additional properties:
export type SolidStartBkndConfig<Env = SolidStartEnv> = RuntimeBkndConfig<Env>;
Use target="_self" on links, anytime your traversing to an external route (like /api/auth/logout which are handled by bknd's middleware) to prevent solid router from intercepting the link.