Agent skill · software engineering · jeremylongshore
clerk-performance-tuning
Optimize Clerk authentication performance.
Why this skill is useful
Adds multiple executable scripts for optimizing Clerk authentication performance that are not widely documented.
What it needs
Requires @clerk/nextjs, next installed locally. Requires clerk account access. About 3k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.
What this skill does
Clerk Performance Tuning Overview Optimize Clerk authentication for best performance. Covers middleware optimization, user data caching, token handling, lazy loading, and edge runtime configuration. Prerequisites Clerk integration working Performance monitoring in place (Lighthouse, Web Vitals) Understanding of Next.js rendering strategies Instructions Step 1: Optimize Middleware (Skip Static Assets) Step 2: Cache User Data For cross-request caching with unstablecache: Step 3: Optimize Token Handling Step 4: Lazy Load Auth Components Step 5: Optimize Server Components Step 6: Edge Runtime for Middleware Output Middleware skipping static assets (fewer auth checks) React cache() deduplicating user fetches within requests Cross-request user profile caching (5-minute TTL) Lazy-loaded auth components reducing bundle size Parallel Suspense boundaries for dashboard rendering Edge Runtime middleware for faster cold starts Error Handling Issue Cause Solution ------- ------- ---------- Slow initial page load Blocking auth calls Use Suspense boundaries for parallel loading High Clerk API latency No caching Use cache() and unstablecache() Large JS bundle All Clerk components loaded Use dynamic() imports for auth UI components Slow middleware cold start Node.js runtime Switch to Edge Runtime on Vercel Stale cached user data Cache not invalidated Invalidate on user.updated webhook Examples Measure Clerk Auth Overhead Resources Next.js Performance Optimization Clerk Quickstart (Next.js) Vercel Edge Runtime Next Steps Proceed to clerk-cost-tuning for cost optimization strategies.
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills jeremylongshore/clerk-performance-tuning