Middleware is in a redirect loop
A matcher that protects the sign-in route itself, or a public page that was marked private by a broader matcher pattern. Users bounce between /sign-in and / forever.
Middleware honest, loops gone
Running Clerk?
Clerk is the fastest way to get a usable signup and login into a Next.js app, and the fastest way to produce a redirect loop when the middleware config does not match the route structure. We work through the middleware, the webhook signing, the Organizations model and the auth() calls that are running in the wrong runtime, and leave the auth path predictable.
What it is
Clerk is a developer-focused authentication platform launched in 2020 by Colin Sidoti and Braden Sidoti. It ships drop-in components for React, Next.js, Remix, Expo and a handful of other frameworks, with a focus on the signup and login UI being usable out of the box rather than needing a week of styling work.
The product covers passwords, passkeys, social connections, multi-factor, Organizations, invitations, SAML for enterprise customers, and a webhook stream through Svix. Pricing has a generous free tier (10k MAU) and scales from there, with Organizations, SSO connections and Enhanced Security moving a project into the Pro or Enterprise tiers. Most problems we see are not with Clerk itself; they are with how the middleware, webhooks and runtime boundaries were wired into a Next.js app that grew faster than the auth code did.
The honest version
No technology is all upside. This is where Clerk earns its place and where it tends to cause trouble.
Sound familiar?
The Clerk problems that bring people to us, and what you have once each one is fixed.
A matcher that protects the sign-in route itself, or a public page that was marked private by a broader matcher pattern. Users bounce between /sign-in and / forever.
Middleware honest, loops gone
Body-parser middleware that read the raw body before the Svix verifier could sign-check it, or an environment variable that holds the wrong signing secret after a key rotation.
Webhooks verified and processed
A Pages Router API route that was not wrapped with the required helper, or an App Router route that is running in a runtime where the auth context is not available.
auth() returns the real user
Production keys set as defaults in the host config and used by a preview branch, so users from the main app can log in to preview environments and vice versa.
Keys scoped per environment
An Organizations plan boundary that nobody realized existed, or a soft limit on pending invites per org that was hit by a bulk onboarding script.
Invites flowing, limits understood
A server clock that is skewed against Clerk's issuance time, or a cache that is holding a token longer than its lifetime. Users log in and get rejected immediately.
Clocks aligned, sessions stable
A Google or Microsoft app whose credentials were rotated without updating Clerk, or a redirect URI that was tightened at the provider and no longer matches.
Social providers working
What we do
Reach out for one looping deploy, or let us own the whole Clerk integration.
How it works
Tell us what's going wrong. We look at it, then tell you plainly what's wrong and what it will cost.
We fix the cause, not the symptom. If something is down, getting it back up comes first.
Backups, monitoring, updates and access, so the same problem can't quietly come back.
You get a plain-language write-up. Or we stay on for hosting, upkeep and new work.
Often found together
We work on the whole stack, so the problem can be wherever it actually is.
Almost always because the matcher is protecting a route that Clerk itself needs to be public, like /sign-in or /sign-up, or because a route that renders the sign-in component is behind the matcher. The fix is to make the matcher explicit about which routes require auth and which do not, and to verify every entry in the pattern against the actual route tree.
Clerk uses Svix for webhook signing, and the verifier requires the exact raw body that was signed. Any JSON parsing middleware that runs before the verifier will change the body subtly and break the signature. The fix is to read the raw body as a buffer, verify the Svix signature, and only then parse the JSON, with the signing secret stored per environment.
If you are already shipping and NextAuth is working, probably not. The migration cost is real: user records need to be imported, session cookies change shape, and any custom callbacks have to be rewritten as Actions or webhooks. If you are starting a new Next.js project or your NextAuth setup has grown into a maintenance burden, Clerk is often the faster path. We will give the honest answer against your actual codebase.
The common causes are a route that is not covered by the clerkMiddleware matcher, a Pages Router API route that was not wrapped with the required helper, or an Edge runtime call that is running outside the context. The fix depends on which, and we usually find it in a few minutes by walking the middleware matcher against the route file tree.
Yes, through SAML connections on the Pro or Enterprise plan, scoped per Organization. Each customer org can have its own SAML provider, and users from that org are routed to it at signin. We set the connection up with the customer's IdP, verify the attribute mapping and leave it documented so future customer configurations are repeatable.
The estimate is free. Send over the repo or a note on what is looping or failing, and we return a scope and a fixed price before any changes go into the middleware.
Free estimate
Middleware, webhooks, Organizations, SSO and the Next.js runtime questions nobody wants to answer twice.
Your message is with a real person, and we'll get back to you soon.
Rather talk now? Call us: