Why We Transitioned to Clerk for Authentication
Turso replaced its homegrown GitHub-only auth with Clerk to add Google login, passkeys, MFA and SSO/SAML without building auth in-house, choosing it over Auth.js, Auth0, Kinde and Hanko mainly for its hosted Account Portal and tight Next.js middleware integration. For the CLI, Clerk's one-minute session cookies were unsuitable, so they used JWT templates to issue 7-day long-lived tokens. Migration ran in three phases (dual-writing new users, bulk migrating existing users with Clerk's script, then cutting over), and users whose GitHub email had changed unnoticed were conservatively locked out to prevent account takeover. Next they plan to move from Account Portal to Clerk Elements for full UI customization.
Related posts
- Next.js authentication using Clerk, Drizzle ORM, and Neon
Neon mediumAdept
Clerk can handle authentication for a Next.js 14 App Router app while Drizzle ORM and Neon's serverless HTTP driver store non-PII data keyed by the Clerk user ID. The walkthrough defines a Drizzle schema, generates and pushes migrations with Drizzle Kit, and protects routes with Clerk's authMiddleware and ClerkProvider/UserButton. It then implements Server Actions that use currentUser() to insert and delete a per-user row. PII stays in Clerk's compliant infrastructure, and only the user ID is referenced in Postgres.
- How to Build a Secure Project Management Platform with Next.js, Clerk, and Neon
Neon mediumAdept
A security-first tutorial for building Kozi, a collaborative project management app, using Next.js, Clerk authentication and a Neon serverless Postgres database accessed through Prisma. Security rests on three layers: Clerk middleware protecting every /app route, server actions as the only path to the database so credentials never reach the client, and cross-checking the requesting user ID against record ownership on every read and write. The guide walks through the Prisma schema, the middleware configuration, sidebar and layout components, and task server actions that verify ownership before mutating data.
- Auth setup with Neon, Keycloak and Koyeb
Neon mediumAdept
Keycloak can use Neon serverless Postgres as its backing store, with the Keycloak server deployed as a container on Koyeb. The steps are: create a dedicated keycloak database and a scoped keycloak_admin role, then deploy Keycloak from a Koyeb template configured through KC_DB_URL, KC_DB_USERNAME, KC_DB_PASSWORD and KC_HOSTNAME. After that, import a sample realm and authenticate a Next.js app through NextAuth.js over OAuth. For production, build an optimized Keycloak image, configure connection pooling, and consider Neon branching and point-in-time restore for recovering Keycloak data.
- Solving the MCP Authentication Headache with Vercel & Better Auth
Neon mediumAdept
Remote MCP servers can authenticate users with OAuth instead of plaintext bearer tokens or UUIDs stored in a client's mcp.json, using Better Auth's MCP plugin together with Vercel's @vercel/mcp-adapter in a Next.js app. Setup touches three files: add the mcp plugin with a login page to the Better Auth config, expose the .well-known/oauth-authorization-server discovery route, and wrap the MCP handler so it resolves the user's session via getMCPSession and returns 401 when none exists. The session's user ID can then scope tool access to that user's own data. Clients such as Cursor, connecting through mcp-remote, open a login popup on first use.
- Handling Auth in a Staging Environment
Neon mediumAdept
Neon Auth stores users, sessions and OAuth data in a neon_auth schema inside the Postgres database, so branching the database also branches auth state via copy-on-write. Each branch gets its own auth endpoint, which lets preview and staging environments test role, permission and OAuth changes against a copy of production users without touching production or creating test accounts by hand. Deleting the branch removes all copied users. It is built on Better Auth, used through the @neondatabase/neon-js SDK, and can be provisioned per PR with a GitHub Action that outputs the branch's auth URL.