Skip to content

feat(auth): Clerk strategy in the shared auth files (from ShipKit) - #107

Merged
lacymorrow merged 2 commits into
mainfrom
lac/clerk-shared
Sep 29, 2026
Merged

lacymorrow merged 2 commits into
mainfrom
lac/clerk-shared

Conversation

@lacymorrow

@lacymorrow lacymorrow commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

What

Bones' half of the Clerk registry item (ShipKit PR lacymorrow/shipkit#377). The four shared auth files are copied from ShipKit byte for byte so npx shadcn add @shipkit/clerk skips them silently, and the two modules they now import exist here as stubs.

  • src/lib/auth/auth-strategy.ts: AUTH_STRATEGY=clerk with both Clerk keys returns "clerk". Unset never picks Clerk (paid, hosted); Better Auth stays the default. Selected but unconfigured falls through to Auth.js or guest, like better-auth without a database.
  • src/lib/auth/session-mapping.ts: mapClerkSession() next to mapBetterAuthSession(), structural so the server User and client UserResource both fit, no Clerk import.
  • src/lib/auth/use-session.ts and src/server/auth.ts: dispatch to @/lib/auth/clerk-client and @/server/clerk/facade when Clerk is active.
  • src/env.ts and .env.example: "clerk" in the AUTH_STRATEGY enum.
  • src/server/clerk/facade.ts, src/lib/auth/clerk-client.ts: stubs (signed out, redirect to /sign-in). The clerk item overwrites them; this is the stub pattern from docs/plans/agent-first-install.md in ShipKit.
  • tests/unit/lib/auth/: strategy and mapping tests from ShipKit.

Proof of work

Check Result
pnpm typecheck pass
pnpm test pass, 9 files, 64 tests
prettier --check on changed files pass
pnpm lint:biome 581 warnings, all pre-existing, no errors
pnpm lint:eslint fails on main already: next lint was removed in Next 16 ("Invalid project directory provided, no such directory: .../lint")
ShipKit scripts/registry-smoke.sh clerk against a fresh clone of this repo's main pass (install, shadcn add @shipkit/clerk, pnpm typecheck)

Without this PR the item still typechecks into Bones (the smoke proves it) but AUTH_STRATEGY=clerk fails env validation at boot, so this needs to land for the item to switch on.

Byte-for-byte copies of ShipKit's src/lib/auth/auth-strategy.ts,
session-mapping.ts, use-session.ts and src/server/auth.ts, which now
dispatch to a Clerk facade when AUTH_STRATEGY=clerk, plus:

- src/env.ts: "clerk" joins the AUTH_STRATEGY / NEXT_PUBLIC_AUTH_STRATEGY
  enum. Clerk is never picked automatically; Better Auth stays the default.
- src/server/clerk/facade.ts and src/lib/auth/clerk-client.ts: stubs with the
  exports the shared files import, no @clerk/nextjs dependency. The clerk
  registry item (lacymorrow/shipkit, lac/clerk-item) overwrites both with the
  real implementation and adds the provider, proxy and components.
- tests/unit/lib/auth: the strategy and session-mapping unit tests from
  ShipKit (both dependency-free).

Verified: pnpm typecheck clean, pnpm test 64 passed, prettier clean on the
changed files. pnpm lint:eslint fails on main already ("next lint" is gone
in Next 16).
@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bones Ready Ready Preview Sep 29, 2026 3:42pm UTC

Request Review

* origin/main:
  chore(tsconfig): typecheck ui and blocks like ShipKit does
  fix(seams): @/.source path, static asset types, lucide-react aligned with ShipKit
  feat(doctor): feature table and doctor report from ShipKit
@lacymorrow
lacymorrow merged commit 8f83911 into main Sep 29, 2026
1 check was pending
@lacymorrow
lacymorrow deleted the lac/clerk-shared branch September 29, 2026 15:40

This branch was successfully deployed

1 active deployment
Preview — 6352a7bc Deployed Sep 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant