Files
bknd/examples/sveltekit
Szymon Rączka 90b4de7093 feat: add SvelteKit adapter
Add framework adapter for SvelteKit with:
- `getApp()` - get bknd app instance
- `serve()` - request handler for hooks.server.ts

Usage in hooks.server.ts:
```typescript
import { serve } from "bknd/adapter/sveltekit";
import config from "../bknd.config";

const bkndHandler = serve(config);

export const handle = async ({ event, resolve }) => {
  if (event.url.pathname.startsWith("/api/")) {
    return bkndHandler(event);
  }
  return resolve(event);
};
```

Includes:
- Adapter implementation (app/src/adapter/sveltekit/)
- Test suite
- Working example (examples/sveltekit/)
- Package exports and types
2025-12-26 17:30:03 +01:00
..
2025-12-26 17:30:03 +01:00
2025-12-26 17:30:03 +01:00
2025-12-26 17:30:03 +01:00
2025-12-26 17:30:03 +01:00
2025-12-26 17:30:03 +01:00
2025-12-26 17:30:03 +01:00
2025-12-26 17:30:03 +01:00
2025-12-26 17:30:03 +01:00

bknd + SvelteKit Example

This example shows how to integrate bknd with SvelteKit.

Setup

bun install
bun run dev

How it works

  1. bknd.config.ts - bknd configuration with database connection, schema, and seed data
  2. src/hooks.server.ts - Routes /api/* requests to bknd
  3. src/routes/+page.server.ts - Uses getApp() to fetch data server-side

API Endpoints

  • GET /api/data/entity/todos - List todos (requires auth)
  • POST /api/auth/password/login - Login

Test Credentials

  • Email: admin@example.com
  • Password: password