Checklist
Is the Clerk publishable key safe to expose?
Short answer. Yes. Clerk's rotate-keys page says the publishable key (pk_test_ or pk_live_) is safe to expose on the frontend, and that you do not rotate it just because it is public. It encodes the Frontend API URL. CLERK_SECRET_KEY (sk_) must stay on the server. A NEXT_PUBLIC_ or VITE_ prefix on that secret puts it in the browser.
Updated 4 Dec 2026
This is a practical checklist, not a guarantee. It is not a penetration test, a compliance audit, or proof that an app is safe to launch.
This page answers the question with the checks, not with a yes that covers every string from Clerk. The publishable key is the public one. CLERK_SECRET_KEY is not. The same question for a payment key is Is the Stripe publishable key safe to expose?. Clerk is the directory entry. How it differs from Supabase Auth is Clerk vs Supabase Auth.
Clerk's pages below were read on 4 Dec 2026. Variable names move. If a step here disagrees with the page it links, follow that page.
What a publishable key is
Clerk's How Clerk works page says a Publishable Key tells the app its Frontend API URL, so the app can find that instance. The key is the Frontend API host, base64-encoded, with pk_test_ in a development instance or pk_live_ in production, and a $ at the end of the decoded value. Clerk's own example decodes pk_test_ZXhhbXBsZS5hY2NvdW50cy5kZXYk to example.accounts.dev$. That is an address, not a password.
Clerk's rotate API keys page says the publishable key is safe to expose on the frontend, and that you do not need to rotate it if it is committed to a repository or otherwise made public.
The Next.js name is NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY. Clerk's environment variables page says that value is pk_test_ in development and pk_live_ in production. On Vite, React Router, and Vue, the client name is VITE_CLERK_PUBLISHABLE_KEY. Those prefixes are in the JavaScript a visitor can open. That is the design for this key. The wider pass is API keys in the frontend.
Development and production are different instances. Clerk's production deployment page says a common mistake is leaving the development keys in place. pk_live_ still belongs in the client. It is the production Frontend API address, passed to <ClerkProvider>. It is not the secret key.
What must stay on the server
CLERK_SECRET_KEY is sk_test_ in development and sk_live_ in production. Clerk's environment variables page says not to expose it on the frontend with a public environment variable. The SDK conventions page says the secret key should never be exposed on the client, and that it is a server-side variable. There is no VITE_ row for the secret key. Vite's VITE_ prefix is only for values you intend the client to see.
Clerk's How Clerk works page says administrative tasks, such as listing users, banning a user, or impersonating a user, run on the server with a secret key the browser cannot read. Those calls go to the Backend API. The Frontend API does not do them. A publishable key cannot stand in for that secret.
| Name | Prefix | Where Clerk says it belongs |
|---|---|---|
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY or VITE_CLERK_PUBLISHABLE_KEY | pk_test_ / pk_live_ | Frontend. Public. |
CLERK_SECRET_KEY | sk_test_ / sk_live_ | Server only. No public prefix. |
CLERK_WEBHOOK_SIGNING_SECRET | whsec_ | Server only. Clerk's rotate page says anyone with it can send verified requests to your webhook endpoint. |
The Dashboard shows a new secret key once. Clerk's production guide says that if you do not have a copy, you add a new key on the API keys page. Store it in the host's environment, then redeploy. A name that starts with NEXT_PUBLIC_ or VITE_ is the wrong store.
What actually checks the caller
A publishable key in the bundle does not decide who can read a row. Clerk's protect content guide says every resource that reads or changes protected data needs its own check: Server Components, Route Handlers, Server Actions, and any external API the app calls. auth() from @clerk/nextjs/server works in those server contexts. auth.protect() redirects a signed-out document request, and returns 404 when an authenticated user is not allowed. For an API request, check the response Clerk documents rather than assuming a redirect.
The same guide says a client-side isSignedIn check is a UX affordance, not a security boundary. By the time that code runs, the component has already been sent to the browser. Hide a button if you want. Guard the handler that reads or writes the data.
Clerk's clerkMiddleware() reference says middleware is not the best place to protect routes. Protect access in the code that touches the data. createRouteMatcher() is deprecated. Do not treat a middleware matcher as the only check.
On a production instance, two origin settings are separate from the key:
- Clerk's production guide says the Frontend API accepts cross-origin requests from any subdomain of the root domain unless you set a subdomain allowlist. Set that allowlist to the hosts you actually serve.
- The same page says to set
authorizedPartiesonclerkMiddleware()orauthenticateRequest(). It is an allowlist of origins. Clerk says that without it, a compromised app on another subdomain of the same root could generate sessions for your app, and that omitting it can expose the app to cross-site request forgery. Use the real origins, such ashttps://example.com, not a guess.
Mistakes in an AI-built app
Clerk's environment page tells an agent to run npx -y clerk@latest env pull, which writes the publishable and secret keys with the framework's names. The failure mode is a later edit that puts the secret on a public prefix.
NEXT_PUBLIC_CLERK_SECRET_KEYorVITE_CLERK_SECRET_KEY. The secret is in the bundle. Clerk's docs forbid that.pk_test_left in the production host, orsk_live_copied into a client variable so the preview "works." Production needspk_live_in the client variable andsk_live_inCLERK_SECRET_KEYon the server. Clerk says a plainenv pull --instance prodoverwrites the development keys localhost uses. Put production keys in the host, not in the file you commit.- A page that checks
isSignedInand then calls a route that never callsauth(). The button is not the check. - A webhook handler that trusts the JSON body and never uses
CLERK_WEBHOOK_SIGNING_SECRET.
How generated code keeps picking the wrong variable is How to keep API keys out of AI-generated code. Lovable, Bolt, and Cursor do not change Clerk's rule. A public prefix on sk_ is still a leaked secret key.
How to check your app
Search the built JavaScript for sk_live_ and sk_test_. A hit is the secret key in the client. pk_live_ or pk_test_ in that output is the publishable key Clerk says to expose.
Search env names. CLERK_SECRET_KEY with no public prefix is the server name. NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and VITE_CLERK_PUBLISHABLE_KEY are the client names. Any NEXT_PUBLIC_ or VITE_ name whose value starts with sk_ is the leak.
Open one route that reads or changes a user's data. It should call auth() or auth.protect() on the server. A client component that returns null when isSignedIn is false does not replace that call.
On the production instance, open the Domains page and confirm the subdomain allowlist, then confirm authorizedParties lists the origins that actually call your app.
Then run a free passive check on the URL you will share. It can see a key that shipped in a public script. It does not call Clerk, and it does not read your Dashboard. The worksheets for the rest of the pass are the checklist pack.
If the secret key was exposed
Rotate it. Clerk's rotate page says the secret key must be kept private, and that you rotate it when it is exposed. Publishable keys are not on that list.
Clerk supports more than one active secret key, so you can add the new key before you delete the old one. On the API keys page for the right app and environment, add a key, copy it once, set CLERK_SECRET_KEY everywhere it is used, redeploy, and confirm a Backend API call works. Clerk shows when each key was last used. Delete the old key only after the new one is in use. Deleting a key that is still in use breaks authentication. Development and production keys are independent. Rotating one does not rotate the other.
A whsec_ webhook signing secret is rotated on its own endpoint, not by replacing the publishable key. Do not rotate pk_ because it appeared in the client. Clerk says that is expected.
FAQ
Is pk_live_ a secret because it says live?
No. Clerk's rotate page says both pk_test_ and pk_live_ are safe to expose on the frontend. pk_live_ is the production Frontend API address. sk_live_ is the production secret key, and that one stays in CLERK_SECRET_KEY on the server.
I committed NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY. Do I rotate it?
No. Clerk says you do not need to rotate a publishable key because it was committed or made public. If the committed file also contains CLERK_SECRET_KEY or sk_live_, rotate that secret key. The publishable key is not the incident.
Does isSignedIn on the client protect the API route?
No. Clerk says that check is for the interface. The component is already in the browser. The route, the Server Action, and any external API need their own server-side check with auth() or auth.protect().
I found sk_test_ in the built JavaScript. What now?
Treat it as copied. Add a new secret key in the Dashboard for that instance, put it only in CLERK_SECRET_KEY, redeploy, then delete the old key. Remove the public prefix from the name so the next build does not include it. Search the new build for sk_test_ and sk_live_ again.
Sources
Checked 4 Dec 2026.
Informational only. This page describes checks and vendor documentation. It is not a security audit, a penetration test, or a certification, and it is not a guarantee.
Newsletter
A short weekly note on new tools and security checklists. No spam, unsubscribe anytime.