Showcase of @buddy-works/identity —
zero-config authentication for apps running behind Buddy tunnels.
Next.js App Router, plain npm, the library installed from the npm registry.
What it demonstrates:
/— user card with the current user's data, rendered twice:- in a Server Component via
getCurrentUser(await headers()), - in a Client Component via
getCurrentUser()(browser, cookie attached automatically).
- in a Server Component via
/admin— page gated server-side byuser.admin./reports— page gated server-side by membership in thefinancegroup (workspace admins also pass). Groups are managed centrally in Buddy./api/whoami— Route Handler usinggetCurrentUser(request).
npm install
npm run dev # http://localhost:3000Locally there is no tunnel, so /.buddy/auth/me is mocked via a rewrite in
next.config.mjs + app/api/mock/me/route.ts. Switch user states with MOCK:
MOCK=owner npm run dev # workspace owner
MOCK=admin npm run dev # workspace admin (default)
MOCK=member npm run dev # regular member — blocked on /admin and /reports
MOCK=finance npm run dev # member of the `finance` group — allowed on /reports
MOCK=logged-out npm run dev # no sessionDisable the mock and let the tunnel intercept /.buddy/auth/me:
MOCK=0 npm run build && MOCK=0 npm run startAccess is managed centrally in the tunnel settings — your code just receives trusted user information.