clerk-bun-nextjs
Next.js 16 example

Clerk auth, wired up by the CLI.

A Next.js 16 app on Bun and Cloudflare Workers, showing protected routes, admin RBAC, webhook user sync, and impersonation.

Explore the stack
zsh — clerk-bun-nextjs
$bun create next-app clerk-bun-nextjs
$clerk init --framework next -y
instance created and linked
keys written to .env.local
@clerk/nextjs installed
$

What this example demonstrates

Every piece is wired end to end, from the middleware down to the database, and deploys to the edge.

CLI-first setup

clerk init provisions the instance, writes env keys, and installs the SDK. No dashboard clicks.

Protected routes

clerkMiddleware guards /dashboard and /admin; the webhook stays public and signature-verified.

Role-based admin

An admin area gated on publicMetadata.role, returning a 404 to everyone else.

Webhook user sync

Clerk events mirror users into Turso (libSQL) over plain HTTP, so it bundles cleanly on Workers.

Session impersonation

Act as another user; the act claim drives a persistent banner and one-click exit.

Edge on Workers

Deployed with OpenNext to Cloudflare Workers, Edge middleware and all.

Built withBun·Next.js 16·Clerk·Turso·Cloudflare Workers